Skip to content

ANSI coloring in REPL buffer is broken #1452

Closed
@rfkm

Description

@rfkm

cider

How to reproduce

  1. Interactively eval the following code:
  (println "foo")
  (println "\u001b[31mbar\u001b[0m")
  (println "baz")
  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions