Cleanup previous PR

Use wcswidth() for line width calculation. Works with emoji and ignores
escape codes automatically. Add changelog entry.
This commit is contained in:
Kovid Goyal 2022-08-31 08:01:52 +05:30
parent b978ff8930
commit afada84f52
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 3 deletions

View File

@ -44,6 +44,8 @@ Detailed list of changes
- macOS: Fix regression in 0.26.0 that caused asking the user for a line of input such as for :ac:`set_tab_title` to not work (:iss:`5447`)
- hints kitten: hyperlink matching: Fix hints occasionally matching text on subsequent line as part of hyperlink (:pull:`5450`)
0.26.1 [2022-08-30]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -16,7 +16,7 @@ from typing import (
from kitty.cli import parse_args
from kitty.cli_stub import HintsCLIOptions
from kitty.constants import website_url
from kitty.fast_data_types import get_options, set_clipboard_string
from kitty.fast_data_types import get_options, set_clipboard_string, wcswidth
from kitty.key_encoding import KeyEvent
from kitty.typing import BossType, KittyCommonOpts
from kitty.utils import (
@ -411,8 +411,10 @@ def convert_text(text: str, cols: int) -> str:
appended = False
for line in full_line.split('\r'):
if line:
escape_codes_len = sum([len(match) for match in kitty_ansi_sanitizer_pat().findall(line)])
lines.append(line.ljust(cols + escape_codes_len, '\0'))
line_sz = wcswidth(line)
if line_sz < cols:
line += '\0' * (cols - line_sz)
lines.append(line)
lines.append('\r')
appended = True
if appended: