]> git.lyx.org Git - lyx.git/blobdiff - src/bufferview_funcs.C
reduce number of calls to LyXText::getFont
[lyx.git] / src / bufferview_funcs.C
index 5559aae990a01b4d9dc13d6fe9704de4fc0f3a96..3135a75461e8840ff99790c423f703b3ca6526e8 100644 (file)
@@ -214,15 +214,15 @@ CurStatus status(BufferView const * bv, DocIterator const & dit)
 namespace {
 
 bool gotoNextInset(LCursor & cur,
-                  vector<InsetBase_code> const & codes, 
+                  vector<InsetBase_code> const & codes,
                   string const & contents)
 {
        LCursor tmpcur = cur;
-       
+
        while (tmpcur) {
                InsetBase const * inset = tmpcur.nextInset();
-               if (inset 
-                   && find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end() 
+               if (inset
+                   && find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end()
                    && (contents.empty() ||
                        static_cast<InsetCommand const *>(inset)->getContents() == contents)) {
                        cur = tmpcur;
@@ -237,7 +237,7 @@ bool gotoNextInset(LCursor & cur,
 }
 
 
-void gotoInset(BufferView * bv, vector<InsetBase_code> const & codes, 
+void gotoInset(BufferView * bv, vector<InsetBase_code> const & codes,
               bool same_content)
 {
        string contents;
@@ -246,22 +246,25 @@ void gotoInset(BufferView * bv, vector<InsetBase_code> const & codes,
 
        if (same_content) {
                InsetBase const * inset = tmpcur.nextInset();
-               if (inset 
+               if (inset
                    && find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end()) {
                        contents = static_cast<InsetCommand const *>(inset)->getContents();
                }
        }
 
        if (!gotoNextInset(tmpcur, codes, contents)) {
-               if (tmpcur != doc_iterator_begin(tmpcur.inset())) {
+               if (bv->cursor() != doc_iterator_begin(bv->buffer()->inset())) {
                        tmpcur.reset(tmpcur.bottom().inset());
-                       if (!gotoNextInset(tmpcur, codes, contents)) 
+                       if (!gotoNextInset(tmpcur, codes, contents)) {
                                bv->cursor().message(_("No more insets"));
+                               return;
+                       }
                } else {
                        bv->cursor().message(_("No more insets"));
+                       return;
                }
        }
-       
+
        tmpcur.clearSelection();
        bv->setCursor(tmpcur);
 }