Fix #134491: Adjust Text Input Offset When Deleting Selection

When a text string is longer than the available space it can be at a
scrolled offset, so that you can edit text that is wider than its
container. When selected text is deleted we don't update this offset,
so it is possible to have newly pasted text scrolled out of view. This
PR decreases the offset by the amount of the selected string that is
currently out of view.

Pull Request: https://projects.blender.org/blender/blender/pulls/134815
This commit is contained in:
Harley Acheson
2025-02-20 02:05:03 +01:00
committed by Harley Acheson
parent 1ef3808030
commit 81262b9421

View File

@@ -3120,6 +3120,13 @@ static bool ui_textedit_delete_selection(uiBut *but, uiTextEdit &text_edit)
changed = true;
}
if (but->ofs > but->selsta) {
/* Decrease the ofset by the amount of the selection that is hidden. Without
* this adjustment, pasting text that doesn't fit in the text field would leave
* the pasted text scrolled out of the view (to the left), see: #134491. */
but->ofs -= (but->ofs - but->selsta);
}
but->pos = but->selend = but->selsta;
return changed;
}