The problem is the use of cursor movement methods to update cursor.
Cursor::forwardPos() steps into insets, which is not always what we
want. The problem here is that there is a math inset just after the
accepted change, and that the cursor steps into it for some reason.
This code is a nightmare anyway.
Fixes: bug #9145
The two fixes here a obviously right, although it is not clear why they are sufficient to fix the bug. Anyway I cannot reproduce any crash with it.
* the first part just conditions a whole if/else to change_next_pos.changed(). Originally, only the if branch was concerned.
* the second part is to avoid calling CursorSlice::backwardPos() when position is 0. Doing this leads to an assertion.
each failure.
There are several places I was not sure what to do. These are marked
by comments beginning "LASSERT:" so they can be found easily. At the
moment, they are at:
Author.cpp:105: // LASSERT: What should we do here?
Author.cpp:121: // LASSERT: What should we do here?
Buffer.cpp:4525: // LASSERT: Is it safe to continue here, or should we just return?
Cursor.cpp:345: // LASSERT: Is it safe to continue here, or should we return?
Cursor.cpp:403: // LASSERT: Is it safe to continue here, or should we return?
Cursor.cpp:1143: // LASSERT: There have been several bugs around this code, that seem
CursorSlice.cpp:83: // LASSERT: This should only ever be called from an InsetMath.
CursorSlice.cpp:92: // LASSERT: This should only ever be called from an InsetMath.
LayoutFile.cpp:303: // LASSERT: Why would this fail?
Text.cpp:995: // LASSERT: Is it safe to continue here?
Using Cursor::setCursor or even BufferView::setCursor is often a bad
idea since it does not run DEPM. In this case (and other cases in
f&replace code) it is better to use BufferView::mouseSetCursor (which
should maybe be renamed...).
When using 'find' and a string is not found, this is not an error or a
surprising event. It is often expected (e.g. after searching through
the whole document for a certain string eventually you will get this
message). The exclamation mark should be reserved for messages that
are unexpected or that need extra attention, such as errors.
The forward flag is used to place the cursor behind the replaced text if it's true.
But it's not correct to move the cursor if it's false. The cursor is in front of the
replacement already after the replaceSelectionWithString() was done.
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.
a special method to find \endregexp{}}, not merely the closing brace.
This is now obsolete, so ok to remove this dead code.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39780 a592a061-630c-0410-9148-cb99ea01b6c8
Corresponding test-case needed a fix as well and now it is passed.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39518 a592a061-630c-0410-9148-cb99ea01b6c8
Added corresponding regression tests findadv-re-01 and -02 for finding these special characters.
Unfortunately, braces {} are a little bit special and don't work yet. Added findadv-re-03 regression test to not forget about this case.
This goes along the line of fixing issues reported by Andrew Parsloe and summarised as #7638.
Last note: Still there will be cases when the Advanced F&R won't work, especially if the text to be found and/or the search pattern is preceded by backslashes or others.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39135 a592a061-630c-0410-9148-cb99ea01b6c8
For example, this wasn't allowing to match '\beta\alpha' in the sequence '\alpha\beta\alpha', as
in the accompanying regression test-case (added case for ignore-format off).
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38888 a592a061-630c-0410-9148-cb99ea01b6c8
For example, this wasn't allowing to match '\beta\alpha' in the sequence '\alpha\beta\alpha', as
in the accompanying regression test-case.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38883 a592a061-630c-0410-9148-cb99ea01b6c8
Added accompanying regression tests for displayed math and numbered equations.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38860 a592a061-630c-0410-9148-cb99ea01b6c8
For example, before this footnotes were not correctly found.
Added also accompanying regression test.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38846 a592a061-630c-0410-9148-cb99ea01b6c8
BufferView::dispatch(), and the screen update is done properly there.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38779 a592a061-630c-0410-9148-cb99ea01b6c8