Skip to content

Fix: caret can fall off-screen after typing on long lines#28

Open
andrewtheart wants to merge 1 commit into
FrozenAssassine:masterfrom
andrewtheart:fix/addcharacter-scroll-consistency
Open

Fix: caret can fall off-screen after typing on long lines#28
andrewtheart wants to merge 1 commit into
FrozenAssassine:masterfrom
andrewtheart:fix/addcharacter-scroll-consistency

Conversation

@andrewtheart

Copy link
Copy Markdown

What

TextActionManager.AddCharacter was the only edit operation still using the line-granularity ScrollManager.ScrollLineIntoViewIfOutside(...) to keep the caret visible after an edit. Every other edit operation uses ScrollManager.UpdateScrollToShowCursor(...):

Edit op Scroll call
Backspace / Delete / AddNewLine / Undo / Redo UpdateScrollToShowCursor
AddCharacter (typing) ScrollLineIntoViewIfOutside ← inconsistent

Why it matters

ScrollLineIntoViewIfOutside only 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 same UpdateScrollToShowCursor(false) helper the rest of the edit pipeline already uses, so caret-follow after typing is consistent with backspace/delete/newline/undo/redo.

Testing

  • Builds clean (TextControlBox.csproj, Release/x64).
  • Behavior: typing past the right edge of a long line now keeps the caret in view, matching the other edit operations.

This fix was developed while using TextControlBox as a vendored editor; contributing it back upstream.

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.
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.

1 participant