]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
Update cursor idx after grid paste if columns are appended
[lyx.git] / src / BufferView.cpp
index ca59fcb4db9f3c0878bd43641b614a181c4fe22a..2eaa43465b5ebc1b53ff303cbf800000efaaa2ba 100644 (file)
@@ -179,13 +179,6 @@ bool findInset(DocIterator & dit, vector<InsetCode> const & codes,
 }
 
 
-/// Looks for next inset with the given code
-void findInset(DocIterator & dit, InsetCode code, bool same_content)
-{
-       findInset(dit, vector<InsetCode>(1, code), same_content);
-}
-
-
 /// Moves cursor to the next inset with one of the given codes.
 void gotoInset(BufferView * bv, vector<InsetCode> const & codes,
               bool same_content)
@@ -202,13 +195,6 @@ void gotoInset(BufferView * bv, vector<InsetCode> const & codes,
 }
 
 
-/// Moves cursor to the next inset with given code.
-void gotoInset(BufferView * bv, InsetCode code, bool same_content)
-{
-       gotoInset(bv, vector<InsetCode>(1, code), same_content);
-}
-
-
 /// A map from a Text to the associated text metrics
 typedef map<Text const *, TextMetrics> TextMetricsCache;
 
@@ -1530,14 +1516,19 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
        }
 
        case LFUN_NOTE_NEXT:
-               gotoInset(this, NOTE_CODE, false);
+               gotoInset(this, { NOTE_CODE }, false);
+               // FIXME: if SinglePar is changed to act on the inner
+               // paragraph, this will not be OK anymore. The update is
+               // useful for auto-open collapsible insets.
+               dr.screenUpdate(Update::SinglePar | Update::FitCursor);
                break;
 
        case LFUN_REFERENCE_NEXT: {
-               vector<InsetCode> tmp;
-               tmp.push_back(LABEL_CODE);
-               tmp.push_back(REF_CODE);
-               gotoInset(this, tmp, true);
+               gotoInset(this, { LABEL_CODE, REF_CODE }, true);
+               // FIXME: if SinglePar is changed to act on the inner
+               // paragraph, this will not be OK anymore. The update is
+               // useful for auto-open collapsible insets.
+               dr.screenUpdate(Update::SinglePar | Update::FitCursor);
                break;
        }
 
@@ -1715,7 +1706,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 
        case LFUN_BIBTEX_DATABASE_ADD: {
                Cursor tmpcur = cur;
-               findInset(tmpcur, BIBTEX_CODE, false);
+               findInset(tmpcur, { BIBTEX_CODE }, false);
                InsetBibtex * inset = getInsetByCode<InsetBibtex>(tmpcur,
                                                BIBTEX_CODE);
                if (inset) {
@@ -1727,7 +1718,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 
        case LFUN_BIBTEX_DATABASE_DEL: {
                Cursor tmpcur = cur;
-               findInset(tmpcur, BIBTEX_CODE, false);
+               findInset(tmpcur, { BIBTEX_CODE }, false);
                InsetBibtex * inset = getInsetByCode<InsetBibtex>(tmpcur,
                                                BIBTEX_CODE);
                if (inset) {
@@ -2860,7 +2851,7 @@ void BufferView::updateMetrics(Update::flags & update_flags)
        int y1 = d->anchor_ypos_ - anchor_pm.ascent();
        // We are now just above the anchor paragraph.
        pit_type pit1 = d->anchor_pit_ - 1;
-       while (y1 >= 0) {
+       for (; pit1 >= 0 && y1 >= 0; --pit1) {
                tm.redoParagraph(pit1);
                ParagraphMetrics & pm = tm.par_metrics_[pit1];
                y1 -= pm.descent();
@@ -2868,9 +2859,6 @@ void BufferView::updateMetrics(Update::flags & update_flags)
                pm.setPosition(y1);
                tm.updatePosCache(pit1);
                y1 -= pm.ascent();
-               if (pit1 == 0)
-                       break;
-               --pit1;
        }
 
        // Redo paragraphs below the anchor if necessary.