If I add a character to the end of a document and then select Undo to remove the character, the lexer is not called to lex. Manually deleting the character is fine and an undo that results in text being added back is fine too.
There's a difference between Document::DeleteChars and Document::Undo:
Document::DeleteChars
Document::Undo
// DeleteChars: if ((pos < LengthNoExcept()) || (pos == 0)) ModifiedAt(pos); else ModifiedAt(pos-1); // Undo: ModifiedAt(action.position);
Potential narrow fix. There may be related issues not fixed by this patch.
diff -r 4b8c335b8c50 src/Document.cxx --- a/src/Document.cxx Thu Dec 18 14:49:28 2025 +1100 +++ b/src/Document.cxx Fri Dec 19 14:16:29 2025 +1100 @@ -1590,7 +1590,10 @@ } cb.PerformUndoStep(); if (action.at != ActionType::container) { - ModifiedAt(action.position); + if ((action.at == ActionType::remove) || (action.position < LengthNoExcept()) || (action.position == 0)) + ModifiedAt(action.position); + else + ModifiedAt(action.position - 1); newPos = action.position; }
Some of this could be hoisted into a common method with DeleteChars but there is an extra clause in the condition for Undo.
DeleteChars
Undo
Log in to post a comment.
There's a difference between
Document::DeleteCharsandDocument::Undo:Potential narrow fix. There may be related issues not fixed by this patch.
Some of this could be hoisted into a common method with
DeleteCharsbut there is an extra clause in the condition forUndo.