mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
In replaceSelectionWithString, do not select the new string
This is a patch from Scott Kostyshak. The problem it solves is as follows: 1. enable continuous spell check. 2. type a misspelled word and press space so that it has a wavy red underline. 3. right-click and choose a suggested replacement word. 4. press the backspace button. Result: nothing happens. If you press the backspace button again, then it works as normal. The selection code was added for the benefit of the spellchecker, but the code has been rewritten since then.
This commit is contained in:
parent
b27f3755ae
commit
dbcfbe5b76
@ -1078,7 +1078,7 @@ void pasteSelection(Cursor & cur, ErrorList & errorList)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void replaceSelectionWithString(Cursor & cur, docstring const & str, bool backwards)
|
void replaceSelectionWithString(Cursor & cur, docstring const & str)
|
||||||
{
|
{
|
||||||
cur.recordUndo();
|
cur.recordUndo();
|
||||||
DocIterator selbeg = cur.selectionBegin();
|
DocIterator selbeg = cur.selectionBegin();
|
||||||
@ -1097,13 +1097,6 @@ void replaceSelectionWithString(Cursor & cur, docstring const & str, bool backwa
|
|||||||
|
|
||||||
// Cut the selection
|
// Cut the selection
|
||||||
cutSelection(cur, true, false);
|
cutSelection(cur, true, false);
|
||||||
|
|
||||||
// select the replacement
|
|
||||||
if (backwards) {
|
|
||||||
selbeg.pos() += str.length();
|
|
||||||
cur.setSelection(selbeg, -int(str.length()));
|
|
||||||
} else
|
|
||||||
cur.setSelection(selbeg, str.length());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,12 +41,9 @@ docstring selection(size_t sel_index);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace using the font of the first selected character and select
|
* Replace using the font of the first selected character and select
|
||||||
* the new string. When \c backwards == false, set anchor before
|
* the new string. Does handle undo.
|
||||||
* cursor; otherwise set cursor before anchor.
|
|
||||||
* Does handle undo.
|
|
||||||
*/
|
*/
|
||||||
void replaceSelectionWithString(Cursor & cur, docstring const & str,
|
void replaceSelectionWithString(Cursor & cur, docstring const & str);
|
||||||
bool backwards);
|
|
||||||
/// If a selection exists, delete it without pushing it to the cut buffer.
|
/// If a selection exists, delete it without pushing it to the cut buffer.
|
||||||
/// Does handle undo.
|
/// Does handle undo.
|
||||||
void replaceSelection(Cursor & cur);
|
void replaceSelection(Cursor & cur);
|
||||||
|
@ -271,7 +271,7 @@ pair<bool, int> replaceOne(BufferView * bv, docstring searchstr,
|
|||||||
if (bv->buffer().isReadonly())
|
if (bv->buffer().isReadonly())
|
||||||
return pair<bool, int>(false, 0);
|
return pair<bool, int>(false, 0);
|
||||||
|
|
||||||
cap::replaceSelectionWithString(cur, replacestr, forward);
|
cap::replaceSelectionWithString(cur, replacestr);
|
||||||
if (forward) {
|
if (forward) {
|
||||||
cur.pos() += replacestr.length();
|
cur.pos() += replacestr.length();
|
||||||
LASSERT(cur.pos() <= cur.lastpos(), /* */);
|
LASSERT(cur.pos() <= cur.lastpos(), /* */);
|
||||||
|
Loading…
Reference in New Issue
Block a user