From 83b27c305d1e6f2b727159d89dd9ef567a410774 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Fri, 4 May 2012 16:09:08 +1000 Subject: Bug #3522250. Group undo for newline with selection. --- src/Editor.cxx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') 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); -- cgit v1.2.3