aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-01-05 07:12:02 +0800
committerGitHub <noreply@github.com>2023-01-05 07:12:02 +0800
commitae64772a88125153a438a0e9e43d5f6bcb4eeb28 (patch)
tree2c086cc06b2aa63549b5bd45716e3ee74a027bf4
parent89232b8b4890824f93121483626af582f13758fe (diff)
downloadrneovim-ae64772a88125153a438a0e9e43d5f6bcb4eeb28.tar.gz
rneovim-ae64772a88125153a438a0e9e43d5f6bcb4eeb28.tar.bz2
rneovim-ae64772a88125153a438a0e9e43d5f6bcb4eeb28.zip
fix(diff): avoid restoring invalid 'foldcolumn' value (#21650)
Use "0" for 'foldcolumn' when w_p_fdc_save is empty, like how "manual" is used for 'foldmethod' when w_p_fdm_save is empty.
-rw-r--r--src/nvim/diff.c2
-rw-r--r--test/functional/ui/diff_spec.lua22
2 files changed, 23 insertions, 1 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 267ec16d72..f9a456a7b2 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -1502,7 +1502,7 @@ void ex_diffoff(exarg_T *eap)
free_string_option(wp->w_p_fdm);
wp->w_p_fdm = xstrdup(*wp->w_p_fdm_save ? wp->w_p_fdm_save : "manual");
free_string_option(wp->w_p_fdc);
- wp->w_p_fdc = xstrdup(wp->w_p_fdc_save);
+ wp->w_p_fdc = xstrdup(*wp->w_p_fdc_save ? wp->w_p_fdc_save : "0");
if (wp->w_p_fdl == 0) {
wp->w_p_fdl = wp->w_p_fdl_save;
diff --git a/test/functional/ui/diff_spec.lua b/test/functional/ui/diff_spec.lua
index dd35f47ca1..dbdf3823ec 100644
--- a/test/functional/ui/diff_spec.lua
+++ b/test/functional/ui/diff_spec.lua
@@ -8,6 +8,8 @@ local insert = helpers.insert
local write_file = helpers.write_file
local dedent = helpers.dedent
local exec = helpers.exec
+local eq = helpers.eq
+local meths = helpers.meths
describe('Diff mode screen', function()
local fname = 'Xtest-functional-diff-screen-1'
@@ -1491,6 +1493,26 @@ it('Align the filler lines when changing text in diff mode', function()
]]}
end)
+it("diff mode doesn't restore invalid 'foldcolumn' value #21647", function()
+ clear()
+ local screen = Screen.new(60, 6)
+ screen:set_default_attr_ids({
+ [0] = {foreground = Screen.colors.Blue, bold = true};
+ })
+ screen:attach()
+ eq('0', meths.get_option_value('foldcolumn', {}))
+ command('diffsplit | bd')
+ screen:expect([[
+ ^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ |
+ ]])
+ eq('0', meths.get_option_value('foldcolumn', {}))
+end)
+
-- oldtest: Test_diff_binary()
it('diff mode works properly if file contains NUL bytes vim-patch:8.2.3925', function()
clear()