Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 9732632

Browse files
committed
Merge pull request #3087 from livecodesebastien/bugfix-16221
[[ Bug 16221 ]] Fix word-selection in field, when mouse moves backwards
2 parents 0279464 + a5c965a commit 9732632

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

docs/notes/bugfix-16221.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Hiliting lines in a field are not accurate or working correctly with word selection

engine/src/paragraf.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,8 +2486,18 @@ int2 MCParagraph::setfocus(int4 x, int4 y, uint2 fixedheight,
24862486
// It then rounds focusedindex down to the beginning of the
24872487
// previous word.
24882488
bptr = indextoblock(originalindex, False);
2489-
originalindex = findwordbreakafter(bptr, originalindex);
2490-
if (originalindex < textsize && !bptr -> textisspace(&text[originalindex]))
2489+
2490+
// SN-2015-10-20: [[ Bug 16221 ]] findwordbreakafter returns
2491+
// the index before the last char of the word, so we need to
2492+
// advance the index returned, but *only* if originalindex
2493+
// is not already the last char of the word, otherwise we
2494+
// get the next word boundary.
2495+
uint2 t_old_index;
2496+
t_old_index = originalindex;
2497+
originalindex = findwordbreakafter(bptr, originalindex);
2498+
2499+
if (originalindex != t_old_index && originalindex < textsize
2500+
&& !bptr -> textisspace(&text[t_old_index]))
24912501
{
24922502
originalindex = findwordbreakafter(bptr, originalindex);
24932503
bptr = indextoblock(originalindex, False);

0 commit comments

Comments
 (0)