]> git.lyx.org Git - lyx.git/blobdiff - src/cursor.C
remove redundant lyxerr.debugging checks; macro LYXERR already checks whether the...
[lyx.git] / src / cursor.C
index 5d72bfff899f041ceae47652e21bfcecaca1b144..f004c23b4b679e36ce8fd51f5f3774097e5567e0 100644 (file)
@@ -93,7 +93,7 @@ namespace {
                it.top().pos() = 0;
                DocIterator et = c;
                et.top().pos() = et.top().asInsetMath()->cell(et.top().idx()).size();
-               for (size_t i = 0; ; ++i) {
+               for (size_t i = 0;; ++i) {
                        int xo;
                        int yo;
                        InsetBase const * inset = &it.inset();
@@ -118,7 +118,7 @@ namespace {
                        double d = (x - xo) * (x - xo) + (y - yo) * (y - yo);
                        // '<=' in order to take the last possible position
                        // this is important for clicking behind \sum in e.g. '\sum_i a'
-                       lyxerr[Debug::DEBUG] << "i: " << i << " d: " << d
+                       LYXERR(Debug::DEBUG) << "i: " << i << " d: " << d
                                << " best: " << best_dist << endl;
                        if (d <= best_dist) {
                                best_dist = d;
@@ -279,7 +279,7 @@ void LCursor::setCursor(DocIterator const & cur)
 
 void LCursor::dispatch(FuncRequest const & cmd0)
 {
-       lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION
+       LYXERR(Debug::DEBUG) << BOOST_CURRENT_FUNCTION
                             << " cmd: " << cmd0 << '\n'
                             << *this << endl;
        if (empty())
@@ -290,7 +290,7 @@ void LCursor::dispatch(FuncRequest const & cmd0)
        LCursor safe = *this;
 
        for (; depth(); pop()) {
-               lyxerr[Debug::DEBUG] << "LCursor::dispatch: cmd: "
+               LYXERR(Debug::DEBUG) << "LCursor::dispatch: cmd: "
                        << cmd0 << endl << *this << endl;
                BOOST_ASSERT(pos() <= lastpos());
                BOOST_ASSERT(idx() <= lastidx());
@@ -308,7 +308,7 @@ void LCursor::dispatch(FuncRequest const & cmd0)
        // it completely to get a 'bomb early' behaviour in case this
        // object will be used again.
        if (!disp_.dispatched()) {
-               lyxerr[Debug::DEBUG] << "RESTORING OLD CURSOR!" << endl;
+               LYXERR(Debug::DEBUG) << "RESTORING OLD CURSOR!" << endl;
                operator=(safe);
                disp_.update(Update::None);
                disp_.dispatched(false);
@@ -786,8 +786,10 @@ bool LCursor::backspace()
                        // [|], can not delete from inside
                        return false;
                } else {
-                       // move to left
-                       popLeft();
+                       if (inMathed())
+                               pullArg();
+                       else
+                               popLeft();
                        return true;
                }
        }
@@ -1117,7 +1119,7 @@ bool LCursor::goUpDown(bool up)
 
 void LCursor::handleFont(string const & font)
 {
-       lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION << ": " << font << endl;
+       LYXERR(Debug::DEBUG) << BOOST_CURRENT_FUNCTION << ": " << font << endl;
        docstring safe;
        if (selection()) {
                macroModeClose();
@@ -1299,6 +1301,7 @@ void LCursor::fixIfBroken()
                               << ", max is " << copy.lastidx()
                               << " at level " << copy.depth()
                               << ". Trying to correct this."  << endl;
+                       lyxerr << "old: " << *this << endl;
                        newdepth = copy.depth() - 1;
                }
                else if (copy.pit() > copy.lastpit()) {
@@ -1306,6 +1309,7 @@ void LCursor::fixIfBroken()
                               << ", max is " << copy.lastpit()
                               << " at level " << copy.depth()
                               << ". Trying to correct this."  << endl;
+                       lyxerr << "old: " << *this << endl;
                        newdepth = copy.depth() - 1;
                }
                else if (copy.pos() > copy.lastpos()) {
@@ -1313,6 +1317,7 @@ void LCursor::fixIfBroken()
                               << ", max is " << copy.lastpos()
                               << " at level " << copy.depth()
                               << ". Trying to correct this."  << endl;
+                       lyxerr << "old: " << *this << endl;
                        newdepth = copy.depth() - 1;
                }
                copy.pop();
@@ -1322,6 +1327,8 @@ void LCursor::fixIfBroken()
        while (depth() > newdepth) {
                pop();
                lyxerr << "correcting cursor to level " << depth() << endl;
+               lyxerr << "new: " << *this << endl;
+               clearSelection();
        }
 }