}
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;
- pullArg();
- return true;
+ } else {
+ // move to left
+ popLeft();
+ return true;
+ }
}
if (inMacroMode()) {
// special behaviour when in last position of cell
if (pos() == lastpos()) {
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;
+ }
// remove markup
- if (one_cell)
- pullArg();
- else
+ if (!one_cell)
inset().idxGlue(idx());
return true;
}
recordUndoInset(cur, Undo::ATOMIC);
else
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;
case LFUN_WORD_DELETE_FORWARD:
recordUndoInset(cur, Undo::ATOMIC);
else
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;
case LFUN_ESCAPE: