Skip to content

Commit

Permalink
don't modify topIndex in handleTextChanged if control has not the foc…
Browse files Browse the repository at this point in the history
…us (#1617)

Co-authored-by: Tobias Melcher <tobias.melcher@sap.com>
  • Loading branch information
tobiasmelcher and tobias-melcher authored Dec 23, 2024
1 parent 238bc0c commit 49fd6b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6046,7 +6046,7 @@ void handleTextChanged(TextChangedEvent event) {
}
int firstLine = content.getLineAtOffset(lastTextChangeStart);
resetCache(firstLine, 0);
if (!isFixedLineHeight() && topIndex > firstLine) {
if (!isFixedLineHeight() && isFocusControl() && topIndex > firstLine) {
topIndex = firstLine;
if (topIndex < 0) {
// TODO: This logging is in place to determine why topIndex is getting set to negative values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4792,6 +4792,11 @@ public void test_notFixedLineHeightDoesntChangeLinePixelIfUnnecessary() {
int firstLinePixel = text.getLinePixel(line);
text.setWordWrap(true); // make non fixed line height
assertEquals(firstLinePixel, text.getLinePixel(line));
shell.setVisible(true);
shell.forceActive();
text.setVisible(true);
assertTrue("setFocus failed",text.setFocus());
assertTrue("text has not focus",text.isFocusControl());
text.replaceTextRange(0, 1, "X");
assertEquals(0, text.getTopIndex());
assertEquals(0, text.getLinePixel(0));
Expand Down

0 comments on commit 49fd6b0

Please sign in to comment.