From a2705e1474ebf68269a8a1779b075c58239dc301 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Wed, 26 Oct 2011 16:02:30 +0000 Subject: [PATCH] Backporting fix for #3821. Allow insertStringAs* to reset the cursor. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@40015 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/CutAndPaste.cpp | 1 + src/Text.cpp | 11 ++++++----- src/Text.h | 4 ++-- status.20x | 3 +++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index c1dc097592..f3163c162a 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -1044,6 +1044,7 @@ void pasteClipboardText(Cursor & cur, ErrorList & errorList, bool asParagraphs) cur.text()->insertStringAsParagraphs(cur, text, cur.current_font); else cur.text()->insertStringAsLines(cur, text, cur.current_font); + cur.setSelection(); } diff --git a/src/Text.cpp b/src/Text.cpp index 7cf206005e..066d0f9cf9 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -756,12 +756,12 @@ void Text::breakParagraph(Cursor & cur, bool inverse_logic) // needed to insert the selection -void Text::insertStringAsLines(DocIterator const & dit, docstring const & str, +void Text::insertStringAsLines(Cursor & cur, docstring const & str, Font const & font) { BufferParams const & bparams = owner_->buffer().params(); - pit_type pit = dit.pit(); - pos_type pos = dit.pos(); + pit_type pit = cur.pit(); + pos_type pos = cur.pos(); // insert the string, don't insert doublespace bool space_inserted = true; @@ -803,12 +803,13 @@ void Text::insertStringAsLines(DocIterator const & dit, docstring const & str, space_inserted = (*cit == ' '); } } + setCursor(cur, pit, pos); } // turn double CR to single CR, others are converted into one // blank. Then insertStringAsLines is called -void Text::insertStringAsParagraphs(DocIterator const & dit, docstring const & str, +void Text::insertStringAsParagraphs(Cursor & cur, docstring const & str, Font const & font) { docstring linestr = str; @@ -830,7 +831,7 @@ void Text::insertStringAsParagraphs(DocIterator const & dit, docstring const & s newline_inserted = false; } } - insertStringAsLines(dit, linestr, font); + insertStringAsLines(cur, linestr, font); } diff --git a/src/Text.h b/src/Text.h index f4110e260f..60b6130cc4 100644 --- a/src/Text.h +++ b/src/Text.h @@ -263,10 +263,10 @@ public: /* these things are for search and replace */ /// needed to insert the selection - void insertStringAsLines(DocIterator const & dit, docstring const & str, + void insertStringAsLines(Cursor & cur, docstring const & str, Font const & font); /// needed to insert the selection - void insertStringAsParagraphs(DocIterator const & dit, docstring const & str, + void insertStringAsParagraphs(Cursor & cur, docstring const & str, Font const & font); /// access to our paragraphs diff --git a/status.20x b/status.20x index d8716ff9fc..4deec4f29a 100644 --- a/status.20x +++ b/status.20x @@ -193,6 +193,9 @@ What's new - Improved scrolling in large tables with vertical alignment (bug 7662). +- Make cursor position after paste independent of where the pasted material + comes from (bug 3821). + * ADVANCED FIND AND REPLACE