mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-07-10 17:53:23 +00:00
Ensure combining chars are zero-width regardless of wcwidth implementation
This commit is contained in:
parent
447a2fe8cf
commit
f5040532c5
1 changed files with 7 additions and 2 deletions
|
|
@ -271,7 +271,8 @@ void
|
|||
screen_draw(Screen *self, uint32_t och) {
|
||||
if (is_ignored_char(och)) return;
|
||||
uint32_t ch = och < 256 ? self->g_charset[och] : och;
|
||||
unsigned int char_width = safe_wcwidth(ch);
|
||||
bool is_cc = is_combining_char(ch);
|
||||
unsigned int char_width = is_cc ? 0 : safe_wcwidth(ch);
|
||||
if (self->columns - self->cursor->x < char_width) {
|
||||
if (self->modes.mDECAWM) {
|
||||
screen_carriage_return(self);
|
||||
|
|
@ -1289,7 +1290,11 @@ screen_wcswidth(Screen UNUSED *self, PyObject *str) {
|
|||
void *data = PyUnicode_DATA(str);
|
||||
Py_ssize_t len = PyUnicode_GET_LENGTH(str), i;
|
||||
unsigned long ans = 0;
|
||||
for (i = 0; i < len; i++) ans += safe_wcwidth(PyUnicode_READ(kind, data, i));
|
||||
for (i = 0; i < len; i++) {
|
||||
char_type ch = PyUnicode_READ(kind, data, i);
|
||||
bool is_cc = is_combining_char(ch);
|
||||
ans += is_cc ? 0 : safe_wcwidth(ch);
|
||||
}
|
||||
return PyLong_FromUnsignedLong(ans);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue