]> git.lyx.org Git - features.git/blobdiff - src/BufferView.cpp
Fix copy of multi-cells in table (#12196)
[features.git] / src / BufferView.cpp
index 29056b13892c8a1d1510247d02620964f0185d14..79bf01f3ce49581027a1d6f6babd3734968e7f8a 100644 (file)
@@ -913,7 +913,7 @@ bool BufferView::moveToPosition(pit_type bottom_pit, pos_type bottom_pos,
        // restoration is inaccurate. If a bookmark was within an inset,
        // it will be restored to the left of the outmost inset that contains
        // the bookmark.
-       if (bottom_pit < int(buffer_.paragraphs().size())) {
+       if (!success && bottom_pit < int(buffer_.paragraphs().size())) {
                dit = doc_iterator_begin(&buffer_);
 
                dit.pit() = bottom_pit;
@@ -984,15 +984,14 @@ void BufferView::scrollToCursor()
 
 bool BufferView::scrollToCursor(DocIterator const & dit, bool const recenter)
 {
-       // We are not properly started yet, delay until resizing is
-       // done.
+       // We are not properly started yet, delay until resizing is done.
        if (height_ == 0)
                return false;
 
        if (recenter)
-         LYXERR(Debug::SCROLLING, "recentering and scrolling to cursor");
+               LYXERR(Debug::SCROLLING, "recentering and scrolling to cursor");
        else
-         LYXERR(Debug::SCROLLING, "scrolling to cursor");
+               LYXERR(Debug::SCROLLING, "scrolling to cursor");
 
        CursorSlice const & bot = dit.bottom();
        TextMetrics & tm = textMetrics(bot.text());
@@ -1016,10 +1015,11 @@ bool BufferView::scrollToCursor(DocIterator const & dit, bool const recenter)
                LBUFERR(!pm.rows().empty());
                // FIXME: smooth scrolling doesn't work in mathed.
                CursorSlice const & cs = dit.innerTextSlice();
-               int offset = coordOffset(dit).y_;
-               int ypos = pm.position() + offset;
+               int const ypos = pm.position() + coordOffset(dit).y_;
+               ParagraphMetrics const & inner_pm =
+                       textMetrics(cs.text()).parMetrics(cs.pit());
                Dimension const & row_dim =
-                       pm.getRow(cs.pos(), dit.boundary()).dim();
+                       inner_pm.getRow(cs.pos(), dit.boundary()).dim();
                int scrolled = 0;
                if (recenter)
                        scrolled = scroll(ypos - height_/2);
@@ -1038,13 +1038,13 @@ bool BufferView::scrollToCursor(DocIterator const & dit, bool const recenter)
                // If the top part of the row falls of the screen, we scroll
                // up to align the top of the row with the top of the screen.
                else if (ypos - row_dim.ascent() < 0 && ypos < height_) {
-                       int ynew = row_dim.ascent();
+                       int const ynew = row_dim.ascent();
                        scrolled = scrollUp(ynew - ypos);
                }
 
                // If the bottom of the row falls of the screen, we scroll down.
                else if (ypos + row_dim.descent() > height_ && ypos > 0) {
-                       int ynew = height_ - row_dim.descent();
+                       int const ynew = height_ - row_dim.descent();
                        scrolled = scrollDown(ypos - ynew);
                }
 
@@ -1058,7 +1058,7 @@ bool BufferView::scrollToCursor(DocIterator const & dit, bool const recenter)
 
        tm.redoParagraph(bot_pit);
        ParagraphMetrics const & pm = tm.parMetrics(bot_pit);
-       int offset = coordOffset(dit).y_;
+       int const offset = coordOffset(dit).y_;
 
        d->anchor_pit_ = bot_pit;
        CursorSlice const & cs = dit.innerTextSlice();
@@ -2264,6 +2264,13 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
        }
 
        case LFUN_COPY:
+               // With multi-cell table content, we pass down to the inset
+               if (cur.inTexted() && cur.selection()
+                   && cur.selectionBegin().idx() != cur.selectionEnd().idx()) {
+                       buffer_.dispatch(cmd, dr);
+                       dispatched = dr.dispatched();
+                       break;
+               }
                cap::copySelection(cur);
                cur.message(_("Copy"));
                break;