LibLine: Correctly slice completion substrings as unicode strings

Ports a fix from Serenity's LibLine.
cee0d979cc
This commit is contained in:
Ali Mohammad Pur 2024-09-19 15:25:17 +02:00 committed by Tim Flynn
commit 5ac0e81c4a
Notes: github-actions[bot] 2024-09-20 10:58:01 +00:00
3 changed files with 13 additions and 6 deletions

View file

@ -383,7 +383,13 @@ void Editor::insert(ByteString const& string)
void Editor::insert(StringView string_view)
{
for (auto ch : Utf8View { string_view })
auto view = Utf8View { string_view };
insert(view);
}
void Editor::insert(Utf8View& view)
{
for (auto ch : view)
insert(ch);
}
@ -1205,7 +1211,7 @@ ErrorOr<void> Editor::handle_read_event()
m_chars_touched_in_the_middle++;
for (auto& view : completion_result.insert)
insert(view.as_string());
insert(view);
auto stderr_stream = TRY(Core::File::standard_error());
TRY(reposition_cursor(*stderr_stream));