-
-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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 crash on Ctrl+X with multiple carets in TextEdit #84901
Conversation
There is a crash when cutting and there is only one line.
Otherwise this fixes the crash. Another issue is cutting a folded line puts the caret on a hidden line. Some minor issues that can be fixed in a separate PR:
And btw both indexes and indices are correct spellings. |
Thank you for the review! Fixed the crash on only one line, handled hidden lines, and fixed the logic for preserving the visually perceived caret column. |
Superseded by #86978. |
Fix #81535 fix #83826
The crash was caused by this function occasionally leaving behind a caret with an invalid column index (larger than the column length), which caused a crash in an unrelated function. The fix is thus to clamp the caret index after cutting to the length of the new column.
However, the function has other problems. It's iteration is broken, since the
backspace()
call would remove carets during iteration, resulting in invalid index errors. So I changed the logic a little while trying to preserve the previous functionality. Also handled multiple carets accumulating on the same line after cutting, only one per line will remain now.To reproduce a broken case fixed by this that doesn't cause a crash set two carets on one line, one on the line after it, and press Ctrl+X.