Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Marked text and undo Bug #675

Closed
bspoel opened this Issue · 1 comment

2 participants

@bspoel

Synopsis: When a line, that contains text marked through markText(), is affected by undo, the marked text disappears.

Reproduce: Open the following page,

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>CodeMirror: Marked text and undo Bug</title>
    <script src="../lib/codemirror.js"></script>
    <link rel="stylesheet" href="../lib/codemirror.css">
  </head>
  <body>
    <h1>CodeMirror: Marked text and undo Bug</h1>
    <textarea id="code" name="code">This is a keyword</textarea>
    <script>
      var editor = CodeMirror.fromTextArea(document.getElementById('code'), {
        mode: 'text/plain',
        tabMode: 'indent'
      });
      onload = function() {
        editor.markText({line:0, ch:0}, {line:0, ch:5}, 'cm-keyword');
      };
    </script>

  </body>
</html>

Type something, press CTRL+Z. 'this' isn't marked anymore, while I expected it to be unaffected.

Occurs in:
CodeMirror 2.32 and the latest development snapshot
FireFox 14.0.1, Chrome 18.0.1025.168 (Developer Build 134367 Linux) Ubuntu 12.04
Ubuntu 12.04

@marijnh
Owner

This is a known issue, but I consider it to be acceptable behavior. On the one hand, it's nice if undo really goes back to the old state, but on the other hand, replacing text will remove any markers on it, and delete+undo can be seen as a replace operation.

On the practical side, doing this properly would reduce the efficiency of the undo history implementation quite a bit, and complicate things significantly, so I'm hesitant to make that change.

@marijnh marijnh closed this issue from a commit
@marijnh marijnh Make undo/redo preserve text markers and bookmarks
Cleans up the implementation of marked ranges, makes the data
structure for markers-within-a-line persistant, and attaches them to
the lines stored in the undo history when necessary.

Closes #675
40c42b5
@marijnh marijnh closed this in 40c42b5
@marijnh marijnh referenced this issue from a commit
@marijnh marijnh Make undo/redo preserve text markers and bookmarks
Cleans up the implementation of marked ranges, makes the data
structure for markers-within-a-line persistant, and attaches them to
the lines stored in the undo history when necessary.

Closes #675
0d3df7e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.