diff options
| author | Maxime Coste <mawww@kakoune.org> | 2018-03-09 23:07:05 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2018-03-09 23:07:05 +1100 |
| commit | 9125b01fa8302c2beb61c5620ead85e24e703631 (patch) | |
| tree | 115530c1cdf1092e19ea19bd64bf6278cf7b0f35 /src/buffer.cc | |
| parent | 950e24949a601a118659a95fc81c81809b36d0e9 (diff) | |
Detect no-op replaces and do not act on them
This avoids recording no-op undo groups.
Diffstat (limited to 'src/buffer.cc')
| -rw-r--r-- | src/buffer.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/buffer.cc b/src/buffer.cc index d065e02e..7a476264 100644 --- a/src/buffer.cc +++ b/src/buffer.cc @@ -613,6 +613,9 @@ BufferCoord Buffer::replace(BufferCoord begin, BufferCoord end, StringView conte content = content.substr(0, content.length() - 1); } + if (std::equal(iterator_at(begin), iterator_at(end), content.begin(), content.end())) + return begin; + auto pos = erase(begin, end); return insert(pos, content); } |
