mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 02:49:46 +00:00
Fix crash with quick search starting with mathed selection
setCursorSelection does not work with math. Copy the method from spellchecker.
This commit is contained in:
parent
571babff5e
commit
babb5b007b
@ -281,6 +281,27 @@ bool searchAllowed(docstring const & str)
|
||||
return true;
|
||||
}
|
||||
|
||||
void setSelection(BufferView * bv, DocIterator const & from, DocIterator const & to)
|
||||
{
|
||||
DocIterator end = to;
|
||||
|
||||
if (from.pit() != end.pit()) {
|
||||
// there are multiple paragraphs in selection
|
||||
Cursor & bvcur = bv->cursor();
|
||||
bvcur.setCursor(from);
|
||||
bvcur.clearSelection();
|
||||
bvcur.selection(true);
|
||||
bvcur.setCursor(end);
|
||||
bvcur.selection(true);
|
||||
} else {
|
||||
// FIXME LFUN
|
||||
// If we used a LFUN, dispatch would do all of this for us
|
||||
int const size = end.pos() - from.pos();
|
||||
bv->putSelectionAt(from, size, false);
|
||||
}
|
||||
bv->processUpdateFlags(Update::Force | Update::FitCursor);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
||||
@ -387,7 +408,7 @@ bool findOne(BufferView * bv, docstring const & searchstr,
|
||||
// restore original selection
|
||||
if (had_selection) {
|
||||
bv->cursor().resetAnchor();
|
||||
bv->setCursorSelectionTo(endcur);
|
||||
setSelection(bv, startcur, endcur);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -464,7 +485,7 @@ int replaceAll(BufferView * bv,
|
||||
if (had_selection) {
|
||||
endcur.fixIfBroken();
|
||||
bv->cursor().resetAnchor();
|
||||
bv->setCursorSelectionTo(endcur);
|
||||
setSelection(bv, startcur, endcur);
|
||||
}
|
||||
|
||||
return num;
|
||||
|
Loading…
Reference in New Issue
Block a user