Only commit undo groups when buffer was modified

This fixes an interaction with kak-lsp that would trigger undo group
commit when setting a buffer option value.
This commit is contained in:
Maxime Coste 2018-09-12 20:02:57 +10:00
parent beb5d00992
commit d3be78cca2
6 changed files with 12 additions and 1 deletions

View File

@ -211,7 +211,11 @@ Vector<String> Context::selections_content() const
void Context::begin_edition() void Context::begin_edition()
{ {
if (m_edition_level >= 0) if (m_edition_level >= 0)
{
if (m_edition_level == 0)
m_edition_timestamp = buffer().timestamp();
++m_edition_level; ++m_edition_level;
}
} }
void Context::end_edition() void Context::end_edition()
@ -220,7 +224,8 @@ void Context::end_edition()
return; return;
kak_assert(m_edition_level != 0); kak_assert(m_edition_level != 0);
if (m_edition_level == 1) if (m_edition_level == 1 and
buffer().timestamp() != m_edition_timestamp)
buffer().commit_undo_group(); buffer().commit_undo_group();
--m_edition_level; --m_edition_level;

View File

@ -134,6 +134,7 @@ private:
void begin_edition(); void begin_edition();
void end_edition(); void end_edition();
int m_edition_level = 0; int m_edition_level = 0;
size_t m_edition_timestamp = 0;
friend struct ScopedEdition; friend struct ScopedEdition;

View File

@ -0,0 +1 @@
Abarbaz<esc>u

View File

@ -0,0 +1 @@
foo

View File

@ -0,0 +1 @@
foo

View File

@ -0,0 +1,2 @@
decl int my_option
hook global InsertChar r %{ eval -buffer %val{buffile} %{ eval "set buffer my_option 1" } }