From a1be9c6102a15dd040c5f4b28840f417daa3a0e2 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Thu, 15 Oct 2009 11:01:13 +0000 Subject: LineDuplicate of a rectangular selection changes the selection to include all the duplicates. --- src/Editor.cxx | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Editor.cxx b/src/Editor.cxx index 82c5895eb..054933569 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -4514,6 +4514,13 @@ void Editor::Duplicate(bool forLine) { forLine = true; } UndoGroup ug(pdoc, sel.Count() > 1); + SelectionPosition last; + const char *eol = ""; + int eolLen = 0; + if (forLine) { + eol = StringFromEOLMode(pdoc->eolMode); + eolLen = istrlen(eol); + } for (size_t r=0; rLineEnd(line)); } char *text = CopyRange(start.Position(), end.Position()); + if (forLine) + pdoc->InsertString(end.Position(), eol, eolLen); + pdoc->InsertString(end.Position() + eolLen, text, SelectionRange(end, start).Length()); + delete []text; + } + if (sel.Count() && sel.IsRectangular()) { + SelectionPosition last = sel.Last(); if (forLine) { - const char *eol = StringFromEOLMode(pdoc->eolMode); - pdoc->InsertCString(end.Position(), eol); - pdoc->InsertString(end.Position() + istrlen(eol), text, SelectionRange(end, start).Length()); - } else { - pdoc->InsertString(end.Position(), text, SelectionRange(end, start).Length()); + int line = pdoc->LineFromPosition(last.Position()); + last = SelectionPosition(last.Position() + pdoc->LineEnd(line) - pdoc->LineStart(line)); } - delete []text; + if (sel.Rectangular().anchor > sel.Rectangular().caret) + sel.Rectangular().anchor = last; + else + sel.Rectangular().caret = last; + SetRectangularRange(); } } -- cgit v1.2.3