From 5def8714ad70e71e07773960269fff5c0c95e7ab Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 14 Jun 2024 06:20:42 +0800 Subject: [PATCH] fix(terminal): set local values of window options (#29326) --- runtime/lua/vim/_defaults.lua | 6 +++--- test/functional/terminal/buffer_spec.lua | 2 +- test/functional/terminal/window_spec.lua | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/runtime/lua/vim/_defaults.lua b/runtime/lua/vim/_defaults.lua index f417bda3fb..8e4562c8ba 100644 --- a/runtime/lua/vim/_defaults.lua +++ b/runtime/lua/vim/_defaults.lua @@ -290,15 +290,15 @@ do vim.bo.undolevels = -1 vim.bo.scrollback = vim.o.scrollback < 0 and 10000 or math.max(1, vim.o.scrollback) vim.bo.textwidth = 0 - vim.wo.wrap = false - vim.wo.list = false + vim.wo[0][0].wrap = false + vim.wo[0][0].list = false -- This is gross. Proper list options support when? local winhl = vim.o.winhighlight if winhl ~= '' then winhl = winhl .. ',' end - vim.wo.winhighlight = winhl .. 'StatusLine:StatusLineTerm,StatusLineNC:StatusLineTermNC' + vim.wo[0][0].winhighlight = winhl .. 'StatusLine:StatusLineTerm,StatusLineNC:StatusLineTermNC' end, }) diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index 4ad0862986..365a4f8035 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -196,7 +196,7 @@ describe(':terminal buffer', function() screen:expect([[ ab^c | {4:~ }| - {17:========== }| + {5:========== }| rows: 2, cols: 50 | {2: } | {18:========== }| diff --git a/test/functional/terminal/window_spec.lua b/test/functional/terminal/window_spec.lua index f85e26a66d..118ca266dd 100644 --- a/test/functional/terminal/window_spec.lua +++ b/test/functional/terminal/window_spec.lua @@ -12,6 +12,26 @@ local eval = n.eval local skip = t.skip local is_os = t.is_os +describe(':terminal window', function() + before_each(clear) + + it('sets local values of window options #29325', function() + command('setglobal wrap list') + command('terminal') + eq({ 0, 0, 1 }, eval('[&l:wrap, &wrap, &g:wrap]')) + eq({ 0, 0, 1 }, eval('[&l:list, &list, &g:list]')) + command('enew') + eq({ 1, 1, 1 }, eval('[&l:wrap, &wrap, &g:wrap]')) + eq({ 1, 1, 1 }, eval('[&l:list, &list, &g:list]')) + command('buffer #') + eq({ 0, 0, 1 }, eval('[&l:wrap, &wrap, &g:wrap]')) + eq({ 0, 0, 1 }, eval('[&l:list, &list, &g:list]')) + command('new') + eq({ 1, 1, 1 }, eval('[&l:wrap, &wrap, &g:wrap]')) + eq({ 1, 1, 1 }, eval('[&l:list, &list, &g:list]')) + end) +end) + describe(':terminal window', function() local screen