]> git.lyx.org Git - features.git/commitdiff
* update the words of a paragraph when the cursor leaves.
authorStefan Schimanski <sts@lyx.org>
Tue, 26 Feb 2008 19:20:12 +0000 (19:20 +0000)
committerStefan Schimanski <sts@lyx.org>
Tue, 26 Feb 2008 19:20:12 +0000 (19:20 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23260 a592a061-630c-0410-9148-cb99ea01b6c8

src/Cursor.cpp
src/Paragraph.cpp
src/insets/InsetText.cpp
src/insets/InsetText.h

index ef62fea62157f49ab01831db0528d1c82222f7ab..531b7bc0bf3e570b3f3bf4179520609b145beb9e 100644 (file)
@@ -1772,6 +1772,15 @@ bool notifyCursorLeaves(Cursor const & old, Cursor & cur)
                if (&old[i].inset() != &cur[i].inset())
                        break;
        }
+
+       // update words if we just moved to another paragraph
+       if (i == old.depth() && i == cur.depth()
+           && !cur.buffer().isClean()
+           && cur.inTexted() && old.inTexted()
+           && cur.pit() != old.pit()) {
+               old.paragraph().updateWords(old.buffer(), old.top());
+               return false;
+       }
        
        // notify everything on top of the common part in old cursor,
        // but stop if the inset claims the cursor to be invalid now
index da573acbd1bb8ea6036e521d10a2f2d14e3443fb..2477165dede936fdbb083f732b49047b3c044650 100644 (file)
@@ -2746,6 +2746,7 @@ void Paragraph::registerWords()
 
 void Paragraph::updateWords(Buffer const & buf, CursorSlice const & sl)
 {
+       BOOST_ASSERT(&sl.paragraph() == this);
        deregisterWords();
        collectWords(buf, sl);
        registerWords();
index b6062d3500edb9f12a44139f4ab0f13baf1e80bd..ddd333d6a0e08e1775ee87c9a9d00bff6a6fbb39 100644 (file)
@@ -474,6 +474,25 @@ void InsetText::updateLabels(Buffer const & buf, ParIterator const & it)
 }
 
 
+bool InsetText::notifyCursorLeaves(Cursor const & old, Cursor & cur)
+{
+       if (cur.buffer().isClean())
+               return Inset::notifyCursorLeaves(old, cur);
+       
+       // find text inset in old cursor
+       Cursor insetCur = old;
+       int scriptSlice = insetCur.find(this);
+       BOOST_ASSERT(scriptSlice != -1);
+       insetCur.cutOff(scriptSlice);
+       BOOST_ASSERT(&insetCur.inset() == this);
+       
+       // update the old paragraph's words
+       insetCur.paragraph().updateWords(insetCur.buffer(), insetCur.top());
+       
+       return Inset::notifyCursorLeaves(old, cur);
+}
+
+
 bool InsetText::completionSupported(Cursor const & cur) const
 {
        Cursor const & bvCur = cur.bv().cursor();
index d88752a4382df5d5ab224d1a8fed41bf13051b43..5f75ce35c368b84cc57ca39589df070ebe985641 100644 (file)
@@ -137,6 +137,8 @@ public:
        virtual void updateLabels(Buffer const &, ParIterator const &);
        ///
        virtual Inset * clone() const;
+       ///
+       virtual bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
 
        ///
        bool completionSupported(Cursor const &) const;