mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
fix invalid cursor after math undo
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10547 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ad41d5f8e7
commit
a2b40d9038
@ -1,3 +1,8 @@
|
||||
2005-10-09 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* text3.C (mathDispatch, dispatch): Dont' record undo steps that don't
|
||||
change anything.
|
||||
|
||||
2005-10-11 Martin Vermeer <martin.vermeer@hut.fi>
|
||||
|
||||
* BufferView_pimpl.C: comment layout change
|
||||
|
@ -1,3 +1,8 @@
|
||||
2005-10-09 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* math_nestinset.C (doDispatch): Don't record undo steps when
|
||||
inserting characters of a macro name (see comment)
|
||||
|
||||
2005-10-04 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* math_macro.C (editXY): new, fix crash (bug 2060)
|
||||
|
@ -651,11 +651,22 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
||||
break;
|
||||
|
||||
case LFUN_SELFINSERT:
|
||||
recordUndo(cur);
|
||||
if (cmd.argument.size() != 1) {
|
||||
recordUndo(cur);
|
||||
cur.insert(cmd.argument);
|
||||
break;
|
||||
}
|
||||
// Don't record undo steps if we are in macro mode and
|
||||
// cmd.argument is the next character of the macro name.
|
||||
// Otherwise we'll get an invalid cursor if we undo after
|
||||
// the macro was finished and the macro is a known command,
|
||||
// e.g. sqrt. LCursor::macroModeClose replaces in this case
|
||||
// the MathUnknownInset with name "frac" by an empty
|
||||
// MathFracInset -> a pos value > 0 is invalid.
|
||||
// A side effect is that an undo before the macro is finished
|
||||
// undoes the complete macro, not only the last character.
|
||||
if (!cur.inMacroMode())
|
||||
recordUndo(cur);
|
||||
if (!interpret(cur, cmd.argument[0])) {
|
||||
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
|
||||
cur.undispatched();
|
||||
|
15
src/text3.C
15
src/text3.C
@ -136,17 +136,20 @@ namespace {
|
||||
|
||||
if (sel.empty()) {
|
||||
const int old_pos = cur.pos();
|
||||
cur.insert(new MathHullInset);
|
||||
cur.insert(new MathHullInset("simple"));
|
||||
BOOST_ASSERT(old_pos == cur.pos());
|
||||
cur.nextInset()->edit(cur, true);
|
||||
cur.dispatch(FuncRequest(LFUN_MATH_MUTATE, "simple"));
|
||||
// don't do that also for LFUN_MATH_MODE
|
||||
// unless you want end up with always changing
|
||||
// to mathrm when opening an inlined inset --
|
||||
// I really hate "LyXfunc overloading"...
|
||||
if (display)
|
||||
cur.dispatch(FuncRequest(LFUN_MATH_DISPLAY));
|
||||
cur.dispatch(FuncRequest(LFUN_INSERT_MATH, cmd.argument));
|
||||
// Avoid an unnecessary undo step if cmd.argument
|
||||
// is empty
|
||||
if (!cmd.argument.empty())
|
||||
cur.dispatch(FuncRequest(LFUN_INSERT_MATH,
|
||||
cmd.argument));
|
||||
} else {
|
||||
// create a macro if we see "\\newcommand"
|
||||
// somewhere, and an ordinary formula
|
||||
@ -155,9 +158,8 @@ namespace {
|
||||
if (sel.find("\\newcommand") == string::npos
|
||||
&& sel.find("\\def") == string::npos)
|
||||
{
|
||||
cur.insert(new MathHullInset);
|
||||
cur.insert(new MathHullInset("simple"));
|
||||
cur.dispatch(FuncRequest(LFUN_RIGHT));
|
||||
cur.dispatch(FuncRequest(LFUN_MATH_MUTATE, "simple"));
|
||||
cur.dispatch(FuncRequest(LFUN_INSERT_MATH, sel));
|
||||
} else {
|
||||
istringstream is(sel);
|
||||
@ -1271,9 +1273,8 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
case LFUN_INSERT_MATH:
|
||||
case LFUN_INSERT_MATRIX:
|
||||
case LFUN_MATH_DELIM: {
|
||||
cur.insert(new MathHullInset);
|
||||
cur.insert(new MathHullInset("simple"));
|
||||
cur.dispatch(FuncRequest(LFUN_RIGHT));
|
||||
cur.dispatch(FuncRequest(LFUN_MATH_MUTATE, "simple"));
|
||||
cur.dispatch(cmd);
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user