mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Fix word selection expansion when going to the left
The proper way to do word-wise selection is to compute the words around both the cursor and the anchor. Note that code is uglier than it should because CursorData::normalAnchor() returns a CursorSlice instead of a DocIterator. Fixes bug #12533.
This commit is contained in:
parent
1677bc5fcd
commit
04a24211a6
@ -137,6 +137,7 @@ public:
|
|||||||
int countInsetsInSelection(InsetCode const & inset) const;
|
int countInsetsInSelection(InsetCode const & inset) const;
|
||||||
|
|
||||||
/// access to normalized selection anchor
|
/// access to normalized selection anchor
|
||||||
|
// FIXME: this should return a full DocIterator
|
||||||
CursorSlice normalAnchor() const;
|
CursorSlice normalAnchor() const;
|
||||||
/// access to real selection anchor
|
/// access to real selection anchor
|
||||||
DocIterator const & realAnchor() const { return anchor_; }
|
DocIterator const & realAnchor() const { return anchor_; }
|
||||||
|
19
src/Text.cpp
19
src/Text.cpp
@ -1410,11 +1410,22 @@ void Text::expandWordSel(Cursor & cur)
|
|||||||
Cursor c = cur;
|
Cursor c = cur;
|
||||||
c.selection(false);
|
c.selection(false);
|
||||||
c.text()->selectWord(c, WHOLE_WORD);
|
c.text()->selectWord(c, WHOLE_WORD);
|
||||||
|
// get selection around anchor too.
|
||||||
|
// FIXME: this cursor is not a proper one. normalAnchor() should
|
||||||
|
// return a DocIterator.
|
||||||
|
Cursor a(cur.bv());
|
||||||
|
a.push_back(cur.normalAnchor());
|
||||||
|
a.text()->selectWord(a, WHOLE_WORD);
|
||||||
// use the correct word boundary, depending on selection direction
|
// use the correct word boundary, depending on selection direction
|
||||||
if (cur.top() > cur.normalAnchor())
|
if (cur.top() > cur.normalAnchor()) {
|
||||||
cur.pos() = c.selEnd().pos();
|
cur.top() = a.selBegin();
|
||||||
else
|
cur.resetAnchor();
|
||||||
cur.pos() = c.selBegin().pos();
|
cur.top() = c.selEnd();
|
||||||
|
} else {
|
||||||
|
cur.top() = a.selEnd();
|
||||||
|
cur.resetAnchor();
|
||||||
|
cur.top() = c.selBegin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user