Ver código fonte

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.
AnotherTest 4 anos atrás
pai
commit
3b9ead985c
1 arquivos alterados com 2 adições e 2 exclusões
  1. 2 2
      Userland/Libraries/LibLine/Editor.cpp

+ 2 - 2
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 anchored_starts = m_anchored_spans_starting.get(i).value_or(empty_styles);
 
 
         auto c = m_buffer[i];
         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()) {
         if (ends.size() || anchored_ends.size()) {
             Style style;
             Style style;
@@ -1560,7 +1560,7 @@ Editor::VTState Editor::actual_rendered_string_length_step(StringMetrics& metric
             current_line.length = 0;
             current_line.length = 0;
             return state;
             return state;
         }
         }
-        if (iscntrl(c) && c != '\n')
+        if (isascii(c) && iscntrl(c) && c != '\n')
             current_line.masked_chars.append({ index, 1, 2 });
             current_line.masked_chars.append({ index, 1, 2 });
         // FIXME: This will not support anything sophisticated
         // FIXME: This will not support anything sophisticated
         ++current_line.length;
         ++current_line.length;