Delayed match-highlight causes bad partial reparses #3787

Closed
opened 2016-01-21 01:14:33 +01:00 by marijnh · 1 comment
marijnh commented 2016-01-21 01:14:33 +01:00 (Migrated from gitlab.com)

Repro steps:

  1. Replace CodeMirror/mode/markdown/index.html with the attached index.html
  2. Open that index.html
  3. Paste in the contents of aaaa.txt (sorry I couldn't make up a small repro case)
  4. In the console run editor.setCursor({line: 485, ch: 28, xRel: 1})

Expected:
Editor scrolls to the indicated position

Actual:
Editor scrolls to the indicated position, and then the highlighting gets messed up, flipping code-style and normal-style text. I'm pretty sure this is because of a reparse/redraw that doesn't start very far up above the upper edge of the viewport.

repro.zip

Repro steps: 1. Replace CodeMirror/mode/markdown/index.html with the attached index.html 2. Open that index.html 3. Paste in the contents of aaaa.txt (sorry I couldn't make up a small repro case) 4. In the console run `editor.setCursor({line: 485, ch: 28, xRel: 1})` Expected: Editor scrolls to the indicated position Actual: Editor scrolls to the indicated position, _and then the highlighting gets messed up_, flipping code-style and normal-style text. I'm pretty sure this is because of a reparse/redraw that doesn't start very far up above the upper edge of the viewport. [repro.zip](https://github.com/codemirror/CodeMirror/files/98438/repro.zip)
marijnh (Migrated from gitlab.com) closed this issue 2016-01-24 15:54:11 +01:00
marijnh commented 2016-01-24 15:55:17 +01:00 (Migrated from gitlab.com)

The mode was, for some reason, keeping state in a variable rather than in its state object, and this kind of corruptions in rare situation are exactly what that causes. Attached patch fixes this.

The mode was, for some reason, keeping state in a variable rather than in its state object, and this kind of corruptions in rare situation are exactly what that causes. Attached patch fixes this.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/codemirror5#3787
No description provided.