From c51bf5a6b24928ac04d0bb129b1b424d4c78f28d Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Mon, 23 Dec 2024 15:39:36 -0600 Subject: [PATCH] fix(terminal): set cursor cell percentage (#31703) Fixes: https://github.com/neovim/neovim/issues/31685 --- src/nvim/terminal.c | 2 ++ test/functional/terminal/cursor_spec.lua | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 61eede5ae1..673a6ef4be 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -1961,9 +1961,11 @@ static void refresh_cursor(Terminal *term) break; case VTERM_PROP_CURSORSHAPE_UNDERLINE: shape_table[SHAPE_IDX_TERM].shape = SHAPE_HOR; + shape_table[SHAPE_IDX_TERM].percentage = 20; break; case VTERM_PROP_CURSORSHAPE_BAR_LEFT: shape_table[SHAPE_IDX_TERM].shape = SHAPE_VER; + shape_table[SHAPE_IDX_TERM].percentage = 25; break; } diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua index 8594a9ce16..12a20ddc0d 100644 --- a/test/functional/terminal/cursor_spec.lua +++ b/test/functional/terminal/cursor_spec.lua @@ -152,7 +152,7 @@ describe(':terminal cursor', function() end) end) - it('can be modified by application #3681', function() + it('can be modified by application #3681 #31685', function() skip(is_os('win'), '#31587') local states = { @@ -181,7 +181,15 @@ describe(':terminal cursor', function() eq(0, screen._mode_info[terminal_mode_idx].blinkon) eq(0, screen._mode_info[terminal_mode_idx].blinkoff) end + eq(v.shape, screen._mode_info[terminal_mode_idx].cursor_shape) + + -- Cell percentages are hard coded for each shape in terminal.c + if v.shape == 'horizontal' then + eq(20, screen._mode_info[terminal_mode_idx].cell_percentage) + elseif v.shape == 'vertical' then + eq(25, screen._mode_info[terminal_mode_idx].cell_percentage) + end end, }) end