mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +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();
|
||||
DocIterator selbeg = cur.selectionBegin();
|
||||
@ -1097,13 +1097,6 @@ void replaceSelectionWithString(Cursor & cur, docstring const & str, bool backwa
|
||||
|
||||
// Cut the selection
|
||||
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
|
||||
* the new string. When \c backwards == false, set anchor before
|
||||
* cursor; otherwise set cursor before anchor.
|
||||
* Does handle undo.
|
||||
* the new string. Does handle undo.
|
||||
*/
|
||||
void replaceSelectionWithString(Cursor & cur, docstring const & str,
|
||||
bool backwards);
|
||||
void replaceSelectionWithString(Cursor & cur, docstring const & str);
|
||||
/// If a selection exists, delete it without pushing it to the cut buffer.
|
||||
/// Does handle undo.
|
||||
void replaceSelection(Cursor & cur);
|
||||
|
@ -271,7 +271,7 @@ pair<bool, int> replaceOne(BufferView * bv, docstring searchstr,
|
||||
if (bv->buffer().isReadonly())
|
||||
return pair<bool, int>(false, 0);
|
||||
|
||||
cap::replaceSelectionWithString(cur, replacestr, forward);
|
||||
cap::replaceSelectionWithString(cur, replacestr);
|
||||
if (forward) {
|
||||
cur.pos() += replacestr.length();
|
||||
LASSERT(cur.pos() <= cur.lastpos(), /* */);
|
||||
|
Loading…
Reference in New Issue
Block a user