Skip to content

Commit

Permalink
don't modify topIndex in handleTextChanged if control has not the focus
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-melcher committed Dec 14, 2024
1 parent 37b22fb commit f0fcbe5
Show file tree
Hide file tree
Showing 2 changed files with 5 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 @@ -4790,6 +4790,10 @@ 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);
text.setVisible(true);
text.setFocus();
assertTrue(text.isFocusControl());
text.replaceTextRange(0, 1, "X");
assertEquals(0, text.getTopIndex());
assertEquals(0, text.getLinePixel(0));
Expand Down

0 comments on commit f0fcbe5

Please sign in to comment.