diff options
author | nyamatongwe <devnull@localhost> | 2012-05-04 16:09:08 +1000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2012-05-04 16:09:08 +1000 |
commit | 83b27c305d1e6f2b727159d89dd9ef567a410774 (patch) | |
tree | b97e8255af6f9bfcbb85619a08f0f80711286aef /src | |
parent | 244dfd4b3b95d1aa044299ac609a882497fbc1d1 (diff) | |
download | scintilla-mirror-83b27c305d1e6f2b727159d89dd9ef567a410774.tar.gz |
Bug #3522250. Group undo for newline with selection.
Diffstat (limited to 'src')
-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); |