TextEdit: Ensure caret is visible after paste#116201
Open
nevido2042 wants to merge 4 commits intogodotengine:masterfrom
Open
TextEdit: Ensure caret is visible after paste#116201nevido2042 wants to merge 4 commits intogodotengine:masterfrom
nevido2042 wants to merge 4 commits intogodotengine:masterfrom
Conversation
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.
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>
# Conflicts: # scene/gui/text_edit.cpp
kitbdev
reviewed
Feb 18, 2026
Contributor
kitbdev
left a comment
There was a problem hiding this comment.
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); |
Contributor
There was a problem hiding this comment.
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); |
Contributor
There was a problem hiding this comment.
If a script overrides it, then it is responsible for adjusting the viewport to the caret . We shouldn't force it to adjust.
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.
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.