aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <unknown>2009-10-15 11:01:13 +0000
committernyamatongwe <unknown>2009-10-15 11:01:13 +0000
commita1be9c6102a15dd040c5f4b28840f417daa3a0e2 (patch)
tree1199c0ec2796da2c52a24ab05ef768411c211b6f
parent3cb3a166e055e98c8efcda619dd8c8a2ff000c68 (diff)
downloadscintilla-mirror-a1be9c6102a15dd040c5f4b28840f417daa3a0e2.tar.gz
LineDuplicate of a rectangular selection changes the selection to include
all the duplicates.
-rw-r--r--src/Editor.cxx27
1 files changed, 21 insertions, 6 deletions
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; r<sel.Count(); r++) {
SelectionPosition start = sel.Range(r).Start();
SelectionPosition end = sel.Range(r).End();
@@ -4523,14 +4530,22 @@ void Editor::Duplicate(bool forLine) {
end = SelectionPosition(pdoc->LineEnd(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();
}
}