aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2012-05-04 16:09:08 +1000
committernyamatongwe <devnull@localhost>2012-05-04 16:09:08 +1000
commit83b27c305d1e6f2b727159d89dd9ef567a410774 (patch)
treeb97e8255af6f9bfcbb85619a08f0f80711286aef
parent244dfd4b3b95d1aa044299ac609a882497fbc1d1 (diff)
downloadscintilla-mirror-83b27c305d1e6f2b727159d89dd9ef567a410774.tar.gz
Bug #3522250. Group undo for newline with selection.
-rw-r--r--src/Editor.cxx13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 9a49580d2..2fb2ea03f 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -5037,14 +5037,23 @@ void Editor::NewLine() {
sel.SetSelection(sel.RangeMain());
// Clear main range and insert line end
- ClearSelection();
+ bool needGroupUndo = !sel.Empty();
+ if (needGroupUndo)
+ pdoc->BeginUndoAction();
+
+ if (!sel.Empty())
+ ClearSelection();
const char *eol = "\n";
if (pdoc->eolMode == SC_EOL_CRLF) {
eol = "\r\n";
} else if (pdoc->eolMode == SC_EOL_CR) {
eol = "\r";
} // else SC_EOL_LF -> "\n" already set
- if (pdoc->InsertCString(sel.MainCaret(), eol)) {
+ bool inserted = pdoc->InsertCString(sel.MainCaret(), eol);
+ // Want to end undo group before NotifyChar as applications often modify text here
+ if (needGroupUndo)
+ pdoc->EndUndoAction();
+ if (inserted) {
SetEmptySelection(sel.MainCaret() + istrlen(eol));
while (*eol) {
NotifyChar(*eol);