fix: setting tabline option not redrawing tabline

With #20374 tabline option is marked with 'statuslines' redraw flag.
But 'statuslines' doesn't redraw tabline. As a result, tabline doesn't
get redrawn when tabline option is set and statuslines get unnecessarily redrawn.

This patch fixes the issue by adding a new redraw flag P_RTABL to redraw
tabline.
This commit is contained in:
shadmansaleh 2022-10-22 13:54:29 +06:00
parent 8371907203
commit a53998ae78
5 changed files with 44 additions and 2 deletions

View File

@ -30,6 +30,7 @@ local type_flags={
local redraw_flags={ local redraw_flags={
statuslines='P_RSTAT', statuslines='P_RSTAT',
tabline = 'P_RTABL',
current_window='P_RWIN', current_window='P_RWIN',
current_window_only='P_RWINONLY', current_window_only='P_RWINONLY',
current_buffer='P_RBUF', current_buffer='P_RBUF',

View File

@ -2648,6 +2648,10 @@ void check_redraw(uint32_t flags)
status_redraw_all(); status_redraw_all();
} }
if ((flags & P_RTABL) || all) { // mark tablines dirty
redraw_tabline = true;
}
if ((flags & P_RBUF) || (flags & P_RWIN) || all) { if ((flags & P_RBUF) || (flags & P_RWIN) || all) {
changed_window_setting(); changed_window_setting();
} }

View File

@ -24,6 +24,7 @@
#define P_NO_MKRC 0x200U ///< don't include in :mkvimrc output #define P_NO_MKRC 0x200U ///< don't include in :mkvimrc output
// when option changed, what to display: // when option changed, what to display:
#define P_RTABL 0x800U ///< redraw tabline
#define P_RSTAT 0x1000U ///< redraw status lines #define P_RSTAT 0x1000U ///< redraw status lines
#define P_RWIN 0x2000U ///< redraw current window and recompute text #define P_RWIN 0x2000U ///< redraw current window and recompute text
#define P_RBUF 0x4000U ///< redraw current buffer and recompute text #define P_RBUF 0x4000U ///< redraw current buffer and recompute text

View File

@ -19,7 +19,7 @@
-- types: bool, number, string -- types: bool, number, string
-- lists: (nil), comma, onecomma, flags, flagscomma -- lists: (nil), comma, onecomma, flags, flagscomma
-- scopes: global, buffer, window -- scopes: global, buffer, window
-- redraw options: statuslines, current_window, curent_window_only, -- redraw options: statuslines, tabline, current_window, curent_window_only,
-- current_buffer, all_windows, curswant -- current_buffer, all_windows, curswant
-- defaults: {condition=#if condition, if_true=default, if_false=default} -- defaults: {condition=#if condition, if_true=default, if_false=default}
-- #if condition: -- #if condition:
@ -2407,7 +2407,7 @@ return {
short_desc=N_("custom format for the console tab pages line"), short_desc=N_("custom format for the console tab pages line"),
type='string', scope={'global'}, type='string', scope={'global'},
modelineexpr=true, modelineexpr=true,
redraw={'statuslines'}, redraw={'tabline'},
varname='p_tal', varname='p_tal',
defaults={if_true=""} defaults={if_true=""}
}, },

View File

@ -84,3 +84,39 @@ describe('ui/ext_tabline', function()
end} end}
end) end)
end) end)
describe("tabline", function()
local screen
before_each(function()
clear()
screen = Screen.new(42, 5)
screen:attach()
end)
it('redraws when tabline option is set', function()
command('set tabline=asdf')
command('set showtabline=2')
screen:expect{grid=[[
{1:asdf }|
^ |
{2:~ }|
{2:~ }|
|
]], attr_ids={
[1] = {reverse = true};
[2] = {bold = true, foreground = Screen.colors.Blue1};
}}
command('set tabline=jkl')
screen:expect{grid=[[
{1:jkl }|
^ |
{2:~ }|
{2:~ }|
|
]], attr_ids={
[1] = {reverse = true};
[2] = {bold = true, foreground = Screen.colors.Blue};
}}
end)
end)