Skip to content

Commit

Permalink
fix(options): using :set fillchars should clear local value
Browse files Browse the repository at this point in the history
  • Loading branch information
zeertzjq committed Nov 16, 2021
1 parent 8c24e14 commit 7528bce
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 33 deletions.
11 changes: 8 additions & 3 deletions src/nvim/option.c
Original file line number Diff line number Diff line change
Expand Up @@ -2665,14 +2665,19 @@ static char *did_set_string_option(int opt_idx, char_u **varp, bool new_value_al
}
} else if (varp == &curwin->w_p_lcs) { // local 'listchars'
errmsg = set_chars_option(curwin, varp, true);
} else if (varp == &p_fcs) { // 'fillchars'
} else if (varp == &p_fcs) { // global 'fillchars'
errmsg = set_chars_option(curwin, varp, false);
if (!errmsg) {
if (errmsg == NULL) {
// The current window is set to use the global 'fillchars' value.
// So clear the window-local value.
if (!(opt_flags & OPT_GLOBAL)) {
clear_string_option(&curwin->w_p_fcs);
}
FOR_ALL_TAB_WINDOWS(tp, wp) {
set_chars_option(wp, &wp->w_p_fcs, true);
}
redraw_all_later(NOT_VALID);
}
redraw_all_later(NOT_VALID);
} else if (varp == &curwin->w_p_fcs) { // local 'fillchars'
errmsg = set_chars_option(curwin, varp, true);
} else if (varp == &p_cedit) { // 'cedit'
Expand Down
76 changes: 46 additions & 30 deletions test/functional/options/chars_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,36 +67,52 @@ describe("'fillchars'", function()
shouldfail('eob:xy') -- two ascii chars
shouldfail('eob:\255', 'eob:<ff>') -- invalid UTF-8
end)
it('has global value', function()
screen:try_resize(50, 5)
insert("foo\nbar")
command('set laststatus=0')
command('1,2fold')
command('vsplit')
command('set fillchars=fold:x')
screen:expect([[
^+-- 2 lines: fooxxxxxxxx│+-- 2 lines: fooxxxxxxx|
~ │~ |
~ │~ |
~ │~ |
|
]])
end)
it('has local window value', function()
screen:try_resize(50, 5)
insert("foo\nbar")
command('set laststatus=0')
command('1,2fold')
command('vsplit')
command('setl fillchars=fold:x')
screen:expect([[
^+-- 2 lines: fooxxxxxxxx│+-- 2 lines: foo·······|
~ │~ |
~ │~ |
~ │~ |
|
]])
end)
end)
it('has global value', function()
screen:try_resize(50, 5)
insert("foo\nbar")
command('set laststatus=0')
command('1,2fold')
command('vsplit')
command('set fillchars=fold:x')
screen:expect([[
^+-- 2 lines: fooxxxxxxxx│+-- 2 lines: fooxxxxxxx|
~ │~ |
~ │~ |
~ │~ |
|
]])
end)
it('has window-local value', function()
screen:try_resize(50, 5)
insert("foo\nbar")
command('set laststatus=0')
command('1,2fold')
command('vsplit')
command('setl fillchars=fold:x')
screen:expect([[
^+-- 2 lines: fooxxxxxxxx│+-- 2 lines: foo·······|
~ │~ |
~ │~ |
~ │~ |
|
]])
end)
it('using :set clears window-local value', function()
screen:try_resize(50, 5)
insert("foo\nbar")
command('set laststatus=0')
command('setl fillchars=fold:x')
command('1,2fold')
command('vsplit')
command('set fillchars&')
screen:expect([[
^+-- 2 lines: foo········│+-- 2 lines: fooxxxxxxx|
~ │~ |
~ │~ |
~ │~ |
|
]])
end)
end)

Expand Down

0 comments on commit 7528bce

Please sign in to comment.