Fix: caret can fall off-screen after typing on long lines#28
Open
andrewtheart wants to merge 1 commit into
Open
Fix: caret can fall off-screen after typing on long lines#28andrewtheart wants to merge 1 commit into
andrewtheart wants to merge 1 commit into
Conversation
AddCharacter was the only edit operation still calling the line-granularity ScrollLineIntoViewIfOutside to keep the caret visible. Every other edit operation (Backspace, Delete, AddNewLine, Undo, Redo) uses UpdateScrollToShowCursor. Because ScrollLineIntoViewIfOutside does not scroll while the caret stays on the same (long) line, a caret typed past the right edge could end up outside the rendered area. Switch AddCharacter to the shared UpdateScrollToShowCursor helper for consistent caret-follow behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
TextActionManager.AddCharacterwas the only edit operation still using the line-granularityScrollManager.ScrollLineIntoViewIfOutside(...)to keep the caret visible after an edit. Every other edit operation usesScrollManager.UpdateScrollToShowCursor(...):UpdateScrollToShowCursorScrollLineIntoViewIfOutside← inconsistentWhy it matters
ScrollLineIntoViewIfOutsideonly scrolls when the caret's line is outside the viewport. While typing on a single long line, the line is always "in view", so it never scrolls to follow the caret horizontally — the caret (and the next typed character) can end up past the right edge, outside the rendered area. The other edit operations don't have this problem because they use the cursor-aware helper.Change
One line in
AddCharacter: use the sameUpdateScrollToShowCursor(false)helper the rest of the edit pipeline already uses, so caret-follow after typing is consistent with backspace/delete/newline/undo/redo.Testing
TextControlBox.csproj, Release/x64).This fix was developed while using TextControlBox as a vendored editor; contributing it back upstream.