From 6c817c811778309476ea0f89e2ca54da5dca3bb2 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 21 Dec 2011 18:56:32 +0000 Subject: [PATCH] Window: do not manage undo groups when an inserter is active --- src/window.cc | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/src/window.cc b/src/window.cc index 9770ca50..6f84097b 100644 --- a/src/window.cc +++ b/src/window.cc @@ -82,8 +82,13 @@ BufferIterator Window::cursor_iterator() const void Window::erase() { - scoped_undo_group undo_group(m_buffer); - erase_noundo(); + if (m_current_inserter == nullptr) + { + scoped_undo_group undo_group(m_buffer); + erase_noundo(); + } + else + erase_noundo(); } void Window::erase_noundo() @@ -119,8 +124,13 @@ static DisplayCoord measure_string(const Window::String& string) void Window::insert(const String& string) { - scoped_undo_group undo_group(m_buffer); - insert_noundo(string); + if (m_current_inserter == nullptr) + { + scoped_undo_group undo_group(m_buffer); + insert_noundo(string); + } + else + insert_noundo(string); } void Window::insert_noundo(const String& string) @@ -132,8 +142,13 @@ void Window::insert_noundo(const String& string) void Window::append(const String& string) { - scoped_undo_group undo_group(m_buffer); - append_noundo(string); + if (m_current_inserter == nullptr) + { + scoped_undo_group undo_group(m_buffer); + append_noundo(string); + } + else + append_noundo(string); } void Window::append_noundo(const String& string) @@ -145,12 +160,19 @@ void Window::append_noundo(const String& string) void Window::replace(const std::string& string) { - scoped_undo_group undo_group(m_buffer); - erase_noundo(); - insert_noundo(string); + if (m_current_inserter == nullptr) + { + scoped_undo_group undo_group(m_buffer); + erase_noundo(); + insert_noundo(string); + } + else + { + erase_noundo(); + insert_noundo(string); + } } - bool Window::undo() { return m_buffer.undo();