summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/editor.cc4
-rw-r--r--src/unit_tests.cc9
2 files changed, 11 insertions, 2 deletions
diff --git a/src/editor.cc b/src/editor.cc
index c03fd396..ae156041 100644
--- a/src/editor.cc
+++ b/src/editor.cc
@@ -558,8 +558,10 @@ void IncrementalInserter::erase()
auto& buffer = m_editor.buffer();
for (auto& sel : m_editor.m_selections)
{
+ if (sel.last() == BufferCoord{0,0})
+ continue;
auto pos = buffer.iterator_at(sel.last());
- buffer.erase(pos-1, pos);
+ buffer.erase(utf8::previous(pos), pos);
}
}
diff --git a/src/unit_tests.cc b/src/unit_tests.cc
index 5058bb91..c0d8a15b 100644
--- a/src/unit_tests.cc
+++ b/src/unit_tests.cc
@@ -94,7 +94,7 @@ void test_editor()
void test_incremental_inserter()
{
- Buffer buffer("test", Buffer::Flags::None, { "test\n", "\n", "youpi\n", "matin\n" });
+ Buffer buffer("test", Buffer::Flags::None, { "test\n", "\n", "yoüpi\n", "matin\n" });
Editor editor(buffer);
editor.select({0,0});
@@ -106,6 +106,13 @@ void test_incremental_inserter()
kak_assert(editor.selections().front().last() == BufferCoord{0 COMMA 0});
kak_assert(*buffer.begin() == L'\n');
}
+ // check utf-8 erase
+ editor.select({3,4});
+ {
+ IncrementalInserter inserter(editor, InsertMode::Insert);
+ inserter.erase();
+ kak_assert(editor.selections().back().last() == BufferCoord{3 COMMA 2});
+ }
kak_assert(not editor.is_editing());
}