Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix undo/redo with autoindent enabled. #461

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eaburns
Copy link
Contributor

@eaburns eaburns commented Nov 10, 2020

Inserting a \n should commit the text, causing a following undo to backup to the \n, but not before it. However, there was a bug when autoindent was enabled that caused \n to not commit the text in most cases, allowing undo to undo beyond the \n.

Specifically in texttype, the variable r is the typed character. At the bottom of the function, if r == '\n', then it commits the text. But when autoindent was enabled, r was overwritten by the loop looking for the first non-space character of the preceeding line. Then the r == \n check was hit, r is the first non-space rune on the preceeding line, not the typed \n, and so no commit is made.

Inserting a \n should commit the text, causing a following undo to backup to the \n, but not before it. However, there was a bug when autoindent was enabled that caused \n to not commit the text in most cases, allowing undo to undo beyond the \n.

Specifically in texttype, the variable r is the typed character. At the bottom of the function, if r == '\n', then it commits the text. But when autoindent was enabled, r was overwritten by the loop looking for the first non-space character of the preceeding line. Then the r == `\n` check was hit, r is the first non-space rune on the preceeding line, not the typed `\n`, and so no commit is made.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant