From 4a9218451dbf6bd5b58addd37f7e334669882ece Mon Sep 17 00:00:00 2001 From: Lucas CHOLLET Date: Tue, 8 Nov 2022 11:47:49 +0100 Subject: [PATCH] LibLine: Consider URL in `actual_rendered_string_length` This allows to not count URLs' metadata for the visible length. --- Userland/Libraries/LibLine/Editor.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Userland/Libraries/LibLine/Editor.cpp b/Userland/Libraries/LibLine/Editor.cpp index 2744f4a1ad..de1f80f290 100644 --- a/Userland/Libraries/LibLine/Editor.cpp +++ b/Userland/Libraries/LibLine/Editor.cpp @@ -1778,6 +1778,7 @@ enum VTState { Bracket = 5, BracketArgsSemi = 7, Title = 9, + URL = 11, }; static VTState actual_rendered_string_length_step(StringMetrics& metrics, size_t index, StringMetrics::LineMetrics& current_line, u32 c, u32 next_c, VTState state, Optional const& mask, Optional const& maximum_line_width = {}, Optional last_return = {}); @@ -1966,6 +1967,8 @@ VTState actual_rendered_string_length_step(StringMetrics& metrics, size_t index, if (c == ']') { if (next_c == '0') state = Title; + if (next_c == '8') + state = URL; return state; } if (c == '[') { @@ -1989,6 +1992,10 @@ VTState actual_rendered_string_length_step(StringMetrics& metrics, size_t index, if (c == 7) state = Free; return state; + case URL: + if (c == '\\') + state = Free; + return state; } return state; }