]> git.lyx.org Git - lyx.git/blobdiff - src/Cursor.cpp
Update it.po
[lyx.git] / src / Cursor.cpp
index 85b3d9857fca3cd5395e9f0252e255fc7e21403c..22b75b5a2613fd67c940db5a42af6f5edbc91fb6 100644 (file)
@@ -95,20 +95,18 @@ DocIterator bruteFind2(Cursor const & c, int x, int y)
                int xo;
                int yo;
                Inset const * inset = &it.inset();
-               map<Inset const *, Geometry> const & data =
-                       c.bv().coordCache().getInsets().getData();
-               map<Inset const *, Geometry>::const_iterator I = data.find(inset);
+               CoordCache const & cache = c.bv().coordCache();
 
                // FIXME: in the case where the inset is not in the cache, this
                // means that no part of it is visible on screen. In this case
                // we don't do elaborate search and we just return the forwarded
                // DocIterator at its beginning.
-               if (I == data.end()) {
+               if (!cache.getInsets().has(inset)) {
                        it.top().pos() = 0;
                        return it;
                }
 
-               Point o = I->second.pos;
+               Point const o = cache.getInsets().xy(inset);
                inset->cursorPos(c.bv(), it.top(), c.boundary(), xo, yo);
                // Convert to absolute
                xo += o.x_;
@@ -552,10 +550,16 @@ void Cursor::checkNewWordPosition()
        if (!inTexted())
                clearNewWordPosition();
        else {
-               // forget the position of the current started word
+               // forget the position of the current new word if
                // 1) the paragraph changes or
-               // 2) the count of nested insets changes
-               if (pit() != new_word_.pit() || depth() != new_word_.depth())
+               // 2) the count of nested insets changes or
+               // 3) the cursor pos is out of paragraph bound
+               if (pit() != new_word_.pit() ||
+                       depth() != new_word_.depth() ||
+                       new_word_.pos() > new_word_.lastpos()) {
+                       clearNewWordPosition();
+               } else if (new_word_.fixIfBroken())
+                       // 4) or the remembered position was "broken"
                        clearNewWordPosition();
                else {
                        FontSpan nw = locateWord(WHOLE_WORD);
@@ -2271,6 +2275,7 @@ bool Cursor::fixIfBroken()
        bool const broken_anchor = anchor_.fixIfBroken();
        
        if (broken_cursor || broken_anchor) {
+               clearNewWordPosition();
                clearSelection();
                return true;
        }