From 947aaf7a5769318f6dfe4d263b02ee1822f15cf2 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Mon, 30 Nov 2015 17:25:03 -0500 Subject: [PATCH] There does not appear to be any need to update the entire Buffer after each entry into mathed. Instead, we just update the TOC for anything the mathed happens to be inside. --- src/Cursor.cpp | 2 +- src/DocIterator.cpp | 9 +++++++++ src/DocIterator.h | 2 ++ src/TocBackend.cpp | 6 +++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Cursor.cpp b/src/Cursor.cpp index c1458dc8a7..09407a3853 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -1303,7 +1303,7 @@ void Cursor::plainInsert(MathAtom const & t) ++pos(); inset().setBuffer(bv_->buffer()); inset().initView(); - forceBufferUpdate(); + checkBufferStructure(); } diff --git a/src/DocIterator.cpp b/src/DocIterator.cpp index 352aa3a65e..a059ad18d2 100644 --- a/src/DocIterator.cpp +++ b/src/DocIterator.cpp @@ -226,6 +226,15 @@ CursorSlice const & DocIterator::innerTextSlice() const } +DocIterator DocIterator::getInnerText() const +{ + DocIterator texted = *this; + while (!texted.inTexted()) + texted.pop_back(); + return texted; +} + + pit_type DocIterator::lastpit() const { return inMathed() ? 0 : text()->paragraphs().size() - 1; diff --git a/src/DocIterator.h b/src/DocIterator.h index 74dd47438f..471f52d4be 100644 --- a/src/DocIterator.h +++ b/src/DocIterator.h @@ -167,6 +167,8 @@ public: Paragraph & innerParagraph() const; /// return the inner text slice. CursorSlice const & innerTextSlice() const; + /// returns a DocIterator for the containing text inset + DocIterator getInnerText() const; /// the first and last positions of a word at top cursor slice /// \warning only works within text! FontSpan locateWord(word_location const loc) const; diff --git a/src/TocBackend.cpp b/src/TocBackend.cpp index e47ca9b630..5599e1f362 100644 --- a/src/TocBackend.cpp +++ b/src/TocBackend.cpp @@ -17,6 +17,7 @@ #include "Buffer.h" #include "BufferParams.h" +#include "Cursor.h" #include "FloatList.h" #include "FuncRequest.h" #include "InsetList.h" @@ -266,8 +267,11 @@ shared_ptr TocBackend::builder(string const & type) // TocItem creation and update should be made in a dedicated function and // updateItem should be rewritten to uniformly update the matching items from // all TOCs. -bool TocBackend::updateItem(DocIterator const & dit) +bool TocBackend::updateItem(DocIterator const & dit_in) { + // we need a text + DocIterator dit = dit_in.getInnerText(); + if (dit.text()->getTocLevel(dit.pit()) == Layout::NOT_IN_TOC) return false; -- 2.39.2