Skip to content

Commit

Permalink
Fix wrong behavior of the revised text widget when moving the cursor …
Browse files Browse the repository at this point in the history
…one line down while already on the last displayed line of the text. See comment in ticket [1871581951] for details.
  • Loading branch information
fvogelnew1 committed Sep 13, 2024
1 parent 70f2dd3 commit fd1a3b1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions generic/tkTextIndex.c
Original file line number Diff line number Diff line change
Expand Up @@ -2945,7 +2945,19 @@ ForwBack(
count = abs(count);

if (forward) {
TkTextIndex indexPtr2 = *indexPtr;

/*
* Check crossing of the end of text boundary. If crossed, adjust
* xOffset so that the returned index will refer to the end of line.
*/

TkTextFindDisplayIndex(textPtr, &indexPtr2, count - 1, NULL);
TkTextFindDisplayIndex(textPtr, indexPtr, count, &xOffset);
if (!TkTextIndexCompare(&indexPtr2, indexPtr)) {
TkTextIndexSetupToEndOfText(indexPtr, textPtr, textPtr->sharedTextPtr->tree);
TkTextFindDisplayIndex(textPtr, indexPtr, 0, &xOffset);
}
} else {
TkTextIndex indexPtr2 = *indexPtr;

Expand Down
2 changes: 1 addition & 1 deletion tests/textMark.test
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ test textMark-6.6 {attempt to move the insert mark beyond peer -endline - bug 34
set res [.p index insert]
} -cleanup {
destroy .p
} -result {1.2}
} -result {1.9}

test textMark-7.1 {MarkFindNext - invalid mark name} -body {
.t mark next bogus
Expand Down

0 comments on commit fd1a3b1

Please sign in to comment.