Skip to content

Fix input field horizontal scroll offset not clamping after text deletion#5708

Open
GautamKumarOffical wants to merge 1 commit into
jesseduffield:masterfrom
GautamKumarOffical:fix/stale-scroll-offset-after-delete
Open

Fix input field horizontal scroll offset not clamping after text deletion#5708
GautamKumarOffical wants to merge 1 commit into
jesseduffield:masterfrom
GautamKumarOffical:fix/stale-scroll-offset-after-delete

Conversation

@GautamKumarOffical

Copy link
Copy Markdown

When text in an input field overflows the visible width, the viewport scrolls right to follow the cursor. However, after deleting characters with backspace, the scroll origin was not clamped back to account for the now-shorter content. This left empty space on the right side of the input while earlier text remained hidden off-screen to the left.

Root cause: updatedCursorAndOrigin in view.go doesn't receive the total content width, so it cannot determine when the content has become shorter than the viewport. After backspace moves the cursor to a position less than the stale origin, the function sets newOrigin = cursor, but this can place the viewport start past the actual content.

Fix: Added GetContentWidth() to TextArea and clamped the horizontal scroll origin in both RenderTextArea and the view-resize path so the viewport never scrolls past the actual content width.

To reproduce:

  1. Open an input field (e.g. commit message, search, filter)
  2. Type enough text to overflow horizontally
  3. Press backspace repeatedly until the text is shorter than the viewport
  4. Observe that the viewport doesn't scroll back left

After fix: The viewport correctly resets to show all remaining content.

Fixes #5633

…tion

When text in an input field overflows the visible width, the viewport
scrolls right to follow the cursor. After deleting characters with
backspace, the scroll origin was not clamped back, leaving empty space
on the right while earlier text remained hidden.

Add GetContentWidth() to TextArea and clamp the horizontal scroll
origin in RenderTextArea and the view resize path so the viewport
never scrolls past the actual content width.

Fixes jesseduffield#5633

Signed-off-by: Gautam Kumar <gautamkumarofficial@users.noreply.github.com>
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.

Input field keeps stale horizontal scroll offset after deletion

1 participant