diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2021-01-31 19:05:48 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-31 19:06:02 +0100 |
commit | 3b9ead985c591e21f20a399147d3ba7f2f44546d (patch) | |
tree | 8343def7323ecafaedc4584a0d78b8054cdd1084 /Userland | |
parent | 521a38d9c50a800fec801f522d8292cc1596f8b5 (diff) | |
download | serenity-3b9ead985c591e21f20a399147d3ba7f2f44546d.zip |
LibLine: Only print ascii characters in caret form
ctype's `iscntrl` truncates its input, making some codepoints appear as
control characters. Avoid this by checking whether the character is in
ascii to begin with.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibLine/Editor.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibLine/Editor.cpp b/Userland/Libraries/LibLine/Editor.cpp index 9a99b6bae4..2bba9c740f 100644 --- a/Userland/Libraries/LibLine/Editor.cpp +++ b/Userland/Libraries/LibLine/Editor.cpp @@ -1205,7 +1205,7 @@ void Editor::refresh_display() auto anchored_starts = m_anchored_spans_starting.get(i).value_or(empty_styles); auto c = m_buffer[i]; - bool should_print_caret = iscntrl(c) && c != '\n'; + bool should_print_caret = isascii(c) && iscntrl(c) && c != '\n'; if (ends.size() || anchored_ends.size()) { Style style; @@ -1560,7 +1560,7 @@ Editor::VTState Editor::actual_rendered_string_length_step(StringMetrics& metric current_line.length = 0; return state; } - if (iscntrl(c) && c != '\n') + if (isascii(c) && iscntrl(c) && c != '\n') current_line.masked_chars.append({ index, 1, 2 }); // FIXME: This will not support anything sophisticated ++current_line.length; |