You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Terminal scrollback search highlights the wrong columns when a line contains a character that grows when lowercased #804
toLocaleLowerCase() can change a string's UTF-16 length. Lowercasing İ (U+0130) yields i + U+0307, one code unit becoming two. So an index into value is not an index into line.
length compounds it: it uses the un-folded query.length, while the match actually spans needle.length folded code units.
The consumer passes these straight to xterm, which selects against the original buffer line:
line "İST build" length 9
lowercased "i̇st build" length 10
search "build" -> { column: 5, length: 5 } the true column in the original is 4
search "st" -> { column: 2, length: 2 } the true column is 1
search on "abc build" -> { column: 4 } correct (ASCII)
Any terminal output containing İ before the match shifts every subsequent match one cell right, so t.select highlights the wrong run of cells. The row and the match count stay correct, which is why it reads as "the search works but the highlight is slightly wrong".
toLocaleLowerCase() is called with no explicit locale, so it follows the browser locale; Turkish and Azeri locales are where this is most likely to be hit in practice.
then map each match to { column: origin[column], length: origin[column + needle.length - 1] + 1 - origin[column] }. indexOf guarantees column + needle.length <= value.length, so the final origin lookup is always in range.
length also becomes correct on its own: it is derived from the original line rather than from the query, which matters when a single folded character spans more than one code unit.
Activity