Window: do not manage undo groups when an inserter is active

This commit is contained in:
Maxime Coste 2011-12-21 18:56:32 +00:00
parent 913ee3f096
commit 6c817c8117

View File

@ -82,8 +82,13 @@ BufferIterator Window::cursor_iterator() const
void Window::erase() void Window::erase()
{ {
if (m_current_inserter == nullptr)
{
scoped_undo_group undo_group(m_buffer); scoped_undo_group undo_group(m_buffer);
erase_noundo(); erase_noundo();
}
else
erase_noundo();
} }
void Window::erase_noundo() void Window::erase_noundo()
@ -119,8 +124,13 @@ static DisplayCoord measure_string(const Window::String& string)
void Window::insert(const String& string) void Window::insert(const String& string)
{ {
if (m_current_inserter == nullptr)
{
scoped_undo_group undo_group(m_buffer); scoped_undo_group undo_group(m_buffer);
insert_noundo(string); insert_noundo(string);
}
else
insert_noundo(string);
} }
void Window::insert_noundo(const String& 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) void Window::append(const String& string)
{ {
if (m_current_inserter == nullptr)
{
scoped_undo_group undo_group(m_buffer); scoped_undo_group undo_group(m_buffer);
append_noundo(string); append_noundo(string);
}
else
append_noundo(string);
} }
void Window::append_noundo(const String& 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) void Window::replace(const std::string& string)
{ {
if (m_current_inserter == nullptr)
{
scoped_undo_group undo_group(m_buffer); scoped_undo_group undo_group(m_buffer);
erase_noundo(); erase_noundo();
insert_noundo(string); insert_noundo(string);
}
else
{
erase_noundo();
insert_noundo(string);
}
} }
bool Window::undo() bool Window::undo()
{ {
return m_buffer.undo(); return m_buffer.undo();