]> git.lyx.org Git - lyx.git/commitdiff
* lyx_cb.C (insertPlaintextFile): delete selection before insertion
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 25 Feb 2007 20:16:45 +0000 (20:16 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Sun, 25 Feb 2007 20:16:45 +0000 (20:16 +0000)
and handle undo correctly (bug 3204)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17345 a592a061-630c-0410-9148-cb99ea01b6c8

src/lyx_cb.C

index f40c18d1e4b9ef5abdc63342fac9fe1d157b993b..d437e107b35f9a3103be3a8561aa4969fa47314c 100644 (file)
@@ -21,6 +21,7 @@
 #include "BufferView.h"
 #include "buffer_funcs.h"
 #include "cursor.h"
+#include "CutAndPaste.h"
 #include "debug.h"
 #include "gettext.h"
 #include "session.h"
@@ -30,6 +31,7 @@
 #include "lyxrc.h"
 #include "lyxtext.h"
 #include "paragraph.h"
+#include "undo.h"
 
 #include "frontends/Alert.h"
 #include "frontends/Application.h"
@@ -329,18 +331,17 @@ void insertPlaintextFile(BufferView * bv, string const & f, bool asParagraph)
        if (tmpstr.empty())
                return;
 
-       // clear the selection
-       LyXText const & text = bv->buffer()->text();
-       if (&text == bv->cursor().innerText())
-               bv->cursor().clearSelection();
+       LCursor & cur = bv->cursor();
+       cap::replaceSelection(cur);
+       recordUndo(cur);
        if (asParagraph)
-               bv->cursor().innerText()->insertStringAsParagraphs(bv->cursor(), tmpstr);
+               cur.innerText()->insertStringAsParagraphs(cur, tmpstr);
        else
-               bv->cursor().innerText()->insertStringAsLines(bv->cursor(), tmpstr);
+               cur.innerText()->insertStringAsLines(cur, tmpstr);
 }
 
 
-// Insert plain text file (if filename is empty, prompt for one)
+// Read plain text file (if filename is empty, prompt for one)
 string getContentsOfPlaintextFile(BufferView * bv, string const & f, bool asParagraph)
 {
        FileName fname(f);