Skip to content

TextEdit: Ensure caret is visible after paste#116201

Open
nevido2042 wants to merge 4 commits intogodotengine:masterfrom
nevido2042:hero
Open

TextEdit: Ensure caret is visible after paste#116201
nevido2042 wants to merge 4 commits intogodotengine:masterfrom
nevido2042:hero

Conversation

@nevido2042
Copy link

Ensure the viewport scrolls correctly after paste so the caret remains visible.

Repro: In the script editor, paste repeatedly near the end of the file and the caret can move out of view.

The adjustment is deferred to make sure scrollbars and layout are updated before repositioning the viewport.

Fixes #115956.

Ensure the viewport scrolls correctly after paste so the caret remains visible.

The adjustment is deferred to make sure scrollbars and layout are updated
before repositioning the viewport.

Fixes godotengine#115956.
@nevido2042 nevido2042 requested a review from a team as a code owner February 12, 2026 10:21
Leeso and others added 3 commits February 12, 2026 19:40
Ensure the viewport scrolls correctly after paste so the caret remains visible.

The adjustment is deferred to make sure scrollbars and layout are updated
before repositioning the viewport.

Fixes godotengine#115956.
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
Copy link
Contributor

@kitbdev kitbdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Someone else claimed the issue, but it has been a week, so I guess its fine.

Comment on lines +4514 to +4515
// Defer to ensure scrollbars/layout are updated after the paste.
callable_mp(this, &TextEdit::adjust_viewport_to_caret).call_deferred(caret_to_adjust);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of deferring, _update_scrollbars can just be called before it if needed.

Also this is only needed in the case of copy-pasting an entire line, and shouldn't be called in all cases after pasting. It can be moved inside the relevant condition in _paste_internal.

Comment on lines +4507 to +4508
// Even if a script overrides paste, keep caret visible.
callable_mp(this, &TextEdit::adjust_viewport_to_caret).call_deferred(caret_to_adjust);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a script overrides it, then it is responsible for adjusting the viewport to the caret . We shouldn't force it to adjust.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Script Editor not scrolling down on copy/paste

3 participants