mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 19:14:51 +00:00
BUG 686: delete empty math box with delete/backspace key
* src/cursor.C: remove nested empty math box * src/mathed/InsetMathNest.C: remove the whole empty math box if it can not be deleted from within git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15990 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5bdedb1fc0
commit
7880841888
33
src/cursor.C
33
src/cursor.C
@ -747,10 +747,22 @@ bool LCursor::backspace()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pos() == 0) {
|
if (pos() == 0) {
|
||||||
if (inset().nargs() == 1 && depth() == 1 && lastpos() == 0)
|
// If empty cell, and not part of a big cell
|
||||||
|
if (lastpos() == 0 && inset().nargs() == 1) {
|
||||||
|
popLeft();
|
||||||
|
// Directly delete empty cell: [|[]] => [|]
|
||||||
|
if (inMathed()) {
|
||||||
|
plainErase();
|
||||||
|
resetAnchor();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// [|], can not delete from inside
|
||||||
return false;
|
return false;
|
||||||
pullArg();
|
} else {
|
||||||
return true;
|
// move to left
|
||||||
|
popLeft();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inMacroMode()) {
|
if (inMacroMode()) {
|
||||||
@ -793,12 +805,19 @@ bool LCursor::erase()
|
|||||||
// special behaviour when in last position of cell
|
// special behaviour when in last position of cell
|
||||||
if (pos() == lastpos()) {
|
if (pos() == lastpos()) {
|
||||||
bool one_cell = inset().nargs() == 1;
|
bool one_cell = inset().nargs() == 1;
|
||||||
if (one_cell && depth() == 1 && lastpos() == 0)
|
if (one_cell && lastpos() == 0) {
|
||||||
|
popLeft();
|
||||||
|
// Directly delete empty cell: [|[]] => [|]
|
||||||
|
if (inMathed()) {
|
||||||
|
plainErase();
|
||||||
|
resetAnchor();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// [|], can not delete from inside
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
// remove markup
|
// remove markup
|
||||||
if (one_cell)
|
if (!one_cell)
|
||||||
pullArg();
|
|
||||||
else
|
|
||||||
inset().idxGlue(idx());
|
inset().idxGlue(idx());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -648,7 +648,11 @@ void InsetMathNest::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
recordUndoInset(cur, Undo::ATOMIC);
|
recordUndoInset(cur, Undo::ATOMIC);
|
||||||
else
|
else
|
||||||
recordUndo(cur, Undo::ATOMIC);
|
recordUndo(cur, Undo::ATOMIC);
|
||||||
cur.backspace();
|
// if the inset can not be removed from within, delete it
|
||||||
|
if (!cur.backspace()) {
|
||||||
|
FuncRequest cmd = FuncRequest(LFUN_CHAR_DELETE_FORWARD);
|
||||||
|
cur.bv().getLyXText()->dispatch(cur, cmd);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_WORD_DELETE_FORWARD:
|
case LFUN_WORD_DELETE_FORWARD:
|
||||||
@ -658,7 +662,11 @@ void InsetMathNest::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
recordUndoInset(cur, Undo::ATOMIC);
|
recordUndoInset(cur, Undo::ATOMIC);
|
||||||
else
|
else
|
||||||
recordUndo(cur, Undo::ATOMIC);
|
recordUndo(cur, Undo::ATOMIC);
|
||||||
cur.erase();
|
// if the inset can not be removed from within, delete it
|
||||||
|
if (!cur.erase()) {
|
||||||
|
FuncRequest cmd = FuncRequest(LFUN_CHAR_DELETE_FORWARD);
|
||||||
|
cur.bv().getLyXText()->dispatch(cur, cmd);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_ESCAPE:
|
case LFUN_ESCAPE:
|
||||||
|
Loading…
Reference in New Issue
Block a user