diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-04-14 09:29:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-14 09:29:38 +0800 |
commit | 4c31a1b807f1c38203661e35059305d63fd0e9f7 (patch) | |
tree | 617408cd5e72389e1a4a0aff52442c4bae0872db /test/functional | |
parent | a92822835521574710a830a7de0e692bf7517fb8 (diff) | |
download | rneovim-4c31a1b807f1c38203661e35059305d63fd0e9f7.tar.gz rneovim-4c31a1b807f1c38203661e35059305d63fd0e9f7.tar.bz2 rneovim-4c31a1b807f1c38203661e35059305d63fd0e9f7.zip |
fix(tui): make setcellwidths() work for non-ambiwidth chars (#28322)
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index e4f26d85c8..7f74bf8176 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -1650,7 +1650,7 @@ describe('TUI', function() eq(expected, rv) end) - it('allows grid to assume wider ambiguous-width characters than host terminal #19686', function() + it('allows grid to assume wider ambiwidth chars than host terminal', function() child_session:request( 'nvim_buf_set_lines', 0, @@ -1694,6 +1694,50 @@ describe('TUI', function() screen:expect(singlewidth_screen) end) + it('allows grid to assume wider non-ambiwidth chars than host terminal', function() + child_session:request( + 'nvim_buf_set_lines', + 0, + 0, + -1, + true, + { ('✓'):rep(60), ('✓'):rep(60) } + ) + child_session:request('nvim_set_option_value', 'cursorline', true, {}) + child_session:request('nvim_set_option_value', 'list', true, {}) + child_session:request('nvim_set_option_value', 'listchars', 'eol:$', { win = 0 }) + feed_data('gg') + local singlewidth_screen = [[ + {13:✓}{12:✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓}| + {12:✓✓✓✓✓✓✓✓✓✓}{15:$}{12: }| + ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓| + ✓✓✓✓✓✓✓✓✓✓{4:$} | + {5:[No Name] [+] }| + | + {3:-- TERMINAL --} | + ]] + -- When grid assumes "✓" to be double-width but host terminal assumes it to be single-width, + -- the second cell of "✓" is a space and the attributes of the "✓" are applied to it. + local doublewidth_screen = [[ + {13:✓}{12: ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ }| + {12:✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ }| + {12:✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ }{15:$}{12: }| + ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ {4:@@@@}| + {5:[No Name] [+] }| + | + {3:-- TERMINAL --} | + ]] + screen:expect(singlewidth_screen) + child_session:request('nvim_set_option_value', 'ambiwidth', 'double', {}) + screen:expect_unchanged() + child_session:request('nvim_call_function', 'setcellwidths', { { { 0x2713, 0x2713, 2 } } }) + screen:expect(doublewidth_screen) + child_session:request('nvim_set_option_value', 'ambiwidth', 'single', {}) + screen:expect_unchanged() + child_session:request('nvim_call_function', 'setcellwidths', { { { 0x2713, 0x2713, 1 } } }) + screen:expect(singlewidth_screen) + end) + it('draws correctly when cursor_address overflows #21643', function() t.skip(is_os('mac'), 'FIXME: crashes/errors on macOS') screen:try_resize(77, 855) |