* update the words of a paragraph when the cursor leaves.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23260 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stefan Schimanski 2008-02-26 19:20:12 +00:00
parent 5622f4b560
commit 249e6b7ac0
4 changed files with 31 additions and 0 deletions

View File

@ -1772,6 +1772,15 @@ bool notifyCursorLeaves(Cursor const & old, Cursor & cur)
if (&old[i].inset() != &cur[i].inset()) if (&old[i].inset() != &cur[i].inset())
break; 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, // notify everything on top of the common part in old cursor,
// but stop if the inset claims the cursor to be invalid now // but stop if the inset claims the cursor to be invalid now

View File

@ -2746,6 +2746,7 @@ void Paragraph::registerWords()
void Paragraph::updateWords(Buffer const & buf, CursorSlice const & sl) void Paragraph::updateWords(Buffer const & buf, CursorSlice const & sl)
{ {
BOOST_ASSERT(&sl.paragraph() == this);
deregisterWords(); deregisterWords();
collectWords(buf, sl); collectWords(buf, sl);
registerWords(); registerWords();

View 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 bool InsetText::completionSupported(Cursor const & cur) const
{ {
Cursor const & bvCur = cur.bv().cursor(); Cursor const & bvCur = cur.bv().cursor();

View File

@ -137,6 +137,8 @@ public:
virtual void updateLabels(Buffer const &, ParIterator const &); virtual void updateLabels(Buffer const &, ParIterator const &);
/// ///
virtual Inset * clone() const; virtual Inset * clone() const;
///
virtual bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
/// ///
bool completionSupported(Cursor const &) const; bool completionSupported(Cursor const &) const;