]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
* GuiDocument.cpp:
[lyx.git] / src / Cursor.cpp
index 572e062876d461d8680adb218b857e59c51eddc2..4785ce32643df208e1bdaa22dc8cd9113faf7e68 100644 (file)
@@ -405,7 +405,10 @@ int Cursor::currentMode()
        LASSERT(!empty(), /**/);
        for (int i = depth() - 1; i >= 0; --i) {
                int res = operator[](i).inset().currentMode();
-               if (res != Inset::UNDECIDED_MODE)
+               bool locked_mode = operator[](i).inset().lockedMode();
+               // Also return UNDECIDED_MODE when the mode is locked,
+               // as in this case it is treated the same as TEXT_MODE
+               if (res != Inset::UNDECIDED_MODE || locked_mode)
                        return res;
        }
        return Inset::TEXT_MODE;
@@ -923,6 +926,8 @@ void Cursor::posVisToRowExtremity(bool left)
 
 CursorSlice Cursor::anchor() const
 {
+       if (!selection())
+               return top();
        LASSERT(anchor_.depth() >= depth(), /**/);
        CursorSlice normal = anchor_[depth() - 1];
        if (depth() < anchor_.depth() && top() <= normal) {