Description
How to reproduce
- Interactively eval the following code:
(println "foo")
(println "\u001b[31mbar\u001b[0m")
(println "baz")
- Then you will see the following output in REPL buffer:
foo <-- default face
bar <-- red face
baz <-- red face(!)
user>
Cause
This is because new output of interactive-eval extends an overlay for ANSI coloring created before.
The following is a part of output of C-u C-x = at 'r' of 'bar' after evaluating (println "\u001b[31mbar\u001b[0m")
:
There is an overlay here:
From 1 to 4
face (foreground-color . "#fb4934")
modification-hooks (ansi-color-freeze-overlay)
Then, the following is new one after evaluating (println "baz")
:
There is an overlay here:
From 1 to 8
face (foreground-color . "#fb4934")
modification-hooks (ansi-color-freeze-overlay)
It cannot be probably said that it is due to CIDER because I suspect this is ansi-color's problem.
I think ansi-color-freeze-overlay
should prevent overlays from being extended at the first place.
I've actually confirmed it works by modifying ansi-color to use insert-behind-hooks
instead of modification-hooks
.
However, I think it is not so difficult to introduce a workaround for this on CIDER's side.
For example, it seems to work for me to use insert
instead of insert-before-markers
here though I'm not sure whether this cause other problems.
(BTW, cider-repl-output-start/cider-repl-output-end seems not to work but it is another issue.)
I'm a novice at elisp (and CIDER internals, of course), so I would be happy if someone investigate this problem further.