fix insert mode erase utf-8 handling, add unit test
This commit is contained in:
parent
59dae9148b
commit
3c8df764be
|
@ -558,8 +558,10 @@ void IncrementalInserter::erase()
|
||||||
auto& buffer = m_editor.buffer();
|
auto& buffer = m_editor.buffer();
|
||||||
for (auto& sel : m_editor.m_selections)
|
for (auto& sel : m_editor.m_selections)
|
||||||
{
|
{
|
||||||
|
if (sel.last() == BufferCoord{0,0})
|
||||||
|
continue;
|
||||||
auto pos = buffer.iterator_at(sel.last());
|
auto pos = buffer.iterator_at(sel.last());
|
||||||
buffer.erase(pos-1, pos);
|
buffer.erase(utf8::previous(pos), pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ void test_editor()
|
||||||
|
|
||||||
void test_incremental_inserter()
|
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 editor(buffer);
|
||||||
|
|
||||||
editor.select({0,0});
|
editor.select({0,0});
|
||||||
|
@ -106,6 +106,13 @@ void test_incremental_inserter()
|
||||||
kak_assert(editor.selections().front().last() == BufferCoord{0 COMMA 0});
|
kak_assert(editor.selections().front().last() == BufferCoord{0 COMMA 0});
|
||||||
kak_assert(*buffer.begin() == L'\n');
|
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());
|
kak_assert(not editor.is_editing());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user