diff options
author | nyamatongwe <unknown> | 2012-05-04 16:09:08 +1000 |
---|---|---|
committer | nyamatongwe <unknown> | 2012-05-04 16:09:08 +1000 |
commit | ef4f64e801487eff26e4fdba2031fab0e3a9a588 (patch) | |
tree | ab4e78385b084d4be6d76164d9569c45c9be8111 | |
parent | 714dc7340d1255ae4018e1ceb793e25cb12cb74f (diff) | |
download | scintilla-mirror-ef4f64e801487eff26e4fdba2031fab0e3a9a588.tar.gz |
Bug #3522250. Group undo for newline with selection.
-rw-r--r-- | src/Editor.cxx | 13 |
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); |