Merge pull request #40323 from bfredl/no_default_again

fix(tests): use builtin default attributes in more places
This commit is contained in:
bfredl
2026-06-19 21:11:13 +02:00
committed by GitHub
9 changed files with 556 additions and 651 deletions

View File

@@ -588,9 +588,6 @@ describe('jobs', function()
it('can redefine callbacks being used by a job', function()
local screen = Screen.new()
screen:set_default_attr_ids({
[1] = { bold = true, foreground = Screen.colors.Blue },
})
source([[
function! g:JobHandler(job_id, data, event)
endfunction
@@ -613,11 +610,6 @@ describe('jobs', function()
it('requires funcrefs for script-local (s:) functions', function()
local screen = Screen.new(60, 5)
screen:set_default_attr_ids({
[1] = { bold = true, foreground = Screen.colors.Blue1 },
[2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
[3] = { bold = true, foreground = Screen.colors.SeaGreen4 },
})
-- Pass job callback names _without_ `function(...)`.
source([[
@@ -631,7 +623,7 @@ describe('jobs', function()
\ })
]])
screen:expect { any = '{2:E120: Using <SID> not in a script context: s:OnEvent}' }
screen:expect { any = '{9:E120: Using <SID> not in a script context: s:OnEvent}' }
end)
it('does not repeat output with slow output handlers', function()

View File

@@ -10,15 +10,6 @@ describe(':digraphs', function()
before_each(function()
clear()
screen = Screen.new(65, 8)
screen:set_default_attr_ids({
[1] = { bold = true, foreground = Screen.colors.Blue1 },
[2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
[3] = { bold = true, foreground = Screen.colors.SeaGreen4 },
[4] = { bold = true },
[5] = { background = Screen.colors.LightGrey },
[6] = { foreground = Screen.colors.Blue1 },
[7] = { bold = true, reverse = true },
})
end)
it('displays digraphs', function()
@@ -26,13 +17,13 @@ describe(':digraphs', function()
feed(':digraphs<CR>')
screen:expect([[
:digraphs |
NU {6:^@} 10 SH {6:^A} 1 SX {6:^B} 2 EX {6:^C} 3 ET {6:^D} 4 |
EQ {6:^E} 5 AK {6:^F} 6 BL {6:^G} 7 BS {6:^H} 8 HT {6:^I} 9 |
LF {6:^@} 10 VT {6:^K} 11 FF {6:^L} 12 CR {6:^M} 13 SO {6:^N} 14 |
SI {6:^O} 15 DL {6:^P} 16 D1 {6:^Q} 17 D2 {6:^R} 18 D3 {6:^S} 19 |
D4 {6:^T} 20 NK {6:^U} 21 SY {6:^V} 22 EB {6:^W} 23 CN {6:^X} 24 |
EM {6:^Y} 25 SB {6:^Z} 26 EC {6:^[} 27 FS {6:^\} 28 GS {6:^]} 29 |
{3:-- More --}^ |
NU {18:^@} 10 SH {18:^A} 1 SX {18:^B} 2 EX {18:^C} 3 ET {18:^D} 4 |
EQ {18:^E} 5 AK {18:^F} 6 BL {18:^G} 7 BS {18:^H} 8 HT {18:^I} 9 |
LF {18:^@} 10 VT {18:^K} 11 FF {18:^L} 12 CR {18:^M} 13 SO {18:^N} 14 |
SI {18:^O} 15 DL {18:^P} 16 D1 {18:^Q} 17 D2 {18:^R} 18 D3 {18:^S} 19 |
D4 {18:^T} 20 NK {18:^U} 21 SY {18:^V} 22 EB {18:^W} 23 CN {18:^X} 24 |
EM {18:^Y} 25 SB {18:^Z} 26 EC {18:^[} 27 FS {18:^\} 28 GS {18:^]} 29 |
{6:-- More --}^ |
]])
end)
end)

View File

@@ -14,10 +14,6 @@ describe('example', function()
before_each(function()
clear()
screen = Screen.new(20, 5)
screen:set_default_attr_ids({
[0] = { bold = true, foreground = Screen.colors.Blue },
[1] = { bold = true, foreground = Screen.colors.Brown },
})
end)
it('screen test', function()
@@ -31,8 +27,7 @@ describe('example', function()
screen:expect([[
line1 |
line^2 |
{0:~ }|
{0:~ }|
{1:~ }|*2
|
]])
end)

View File

@@ -159,20 +159,15 @@ describe('print', function()
it('blank line in message works', function()
local screen = Screen.new(40, 8)
screen:set_default_attr_ids({
[0] = { bold = true, foreground = Screen.colors.Blue },
[1] = { bold = true, foreground = Screen.colors.SeaGreen },
[2] = { bold = true, reverse = true },
})
feed([[:lua print('\na')<CR>]])
screen:expect {
grid = [[
|
{0:~ }|*3
{2: }|
{1:~ }|*3
{3: }|
|
a |
{1:Press ENTER or type command to continue}^ |
{6:Press ENTER or type command to continue}^ |
]],
}
feed('<CR>')
@@ -180,12 +175,12 @@ describe('print', function()
screen:expect {
grid = [[
|
{0:~ }|*2
{2: }|
{1:~ }|*2
{3: }|
b |
|
c |
{1:Press ENTER or type command to continue}^ |
{6:Press ENTER or type command to continue}^ |
]],
}
end)
@@ -196,12 +191,6 @@ describe('debug.debug', function()
before_each(function()
screen = Screen.new()
screen:set_default_attr_ids {
[0] = { bold = true, foreground = 255 },
[1] = { bold = true, reverse = true },
E = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
cr = { bold = true, foreground = Screen.colors.SeaGreen4 },
}
end)
it('works', function()
@@ -216,8 +205,8 @@ describe('debug.debug', function()
screen:expect {
grid = [[
|
{0:~ }|*10
{1: }|
{1:~ }|*10
{3: }|
nil |
lua_debug> ^ |
]],
@@ -225,8 +214,8 @@ describe('debug.debug', function()
feed('print("TEST")\n')
screen:expect([[
|
{0:~ }|*8
{1: }|
{1:~ }|*8
{3: }|
nil |
lua_debug> print("TEST") |
TEST |
@@ -235,40 +224,40 @@ describe('debug.debug', function()
feed('<C-c>')
screen:expect([[
|
{0:~ }|*2
{1: }|
{1:~ }|*2
{3: }|
nil |
lua_debug> print("TEST") |
TEST |
|
{E:E5108: Lua: [string ":lua"]:5: attempt to perform ari}|
{E:thmetic on local 'a' (a nil value)} |
{E:stack traceback:} |
{E: [string ":lua"]:5: in function 'Test'} |
{E: [string ":lua"]:1: in main chunk} |
Interrupt: {cr:Press ENTER or type command to continue}^ |
{9:E5108: Lua: [string ":lua"]:5: attempt to perform ari}|
{9:thmetic on local 'a' (a nil value)} |
{9:stack traceback:} |
{9: [string ":lua"]:5: in function 'Test'} |
{9: [string ":lua"]:1: in main chunk} |
Interrupt: {6:Press ENTER or type command to continue}^ |
]])
feed('<C-l>:lua Test()\n')
screen:expect([[
|
{0:~ }|*10
{1: }|
{1:~ }|*10
{3: }|
nil |
lua_debug> ^ |
]])
feed('\n')
screen:expect([[
|
{0:~ }|*4
{1: }|
{1:~ }|*4
{3: }|
nil |
lua_debug> |
{E:E5108: Lua: [string ":lua"]:5: attempt to perform ari}|
{E:thmetic on local 'a' (a nil value)} |
{E:stack traceback:} |
{E: [string ":lua"]:5: in function 'Test'} |
{E: [string ":lua"]:1: in main chunk} |
{cr:Press ENTER or type command to continue}^ |
{9:E5108: Lua: [string ":lua"]:5: attempt to perform ari}|
{9:thmetic on local 'a' (a nil value)} |
{9:stack traceback:} |
{9: [string ":lua"]:5: in function 'Test'} |
{9: [string ":lua"]:1: in main chunk} |
{6:Press ENTER or type command to continue}^ |
]])
end)
@@ -278,7 +267,7 @@ describe('debug.debug', function()
screen:expect {
grid = [[
|
{0:~ }|*12
{1:~ }|*12
lua_debug> ^ |
]],
}
@@ -286,32 +275,32 @@ describe('debug.debug', function()
feed('conttt<cr>') -- misspelled cont; invalid syntax
screen:expect([[
|
{0:~ }|*8
{1: }|
{1:~ }|*8
{3: }|
lua_debug> conttt |
{E:E5115: Loading Lua debug string: (debug command):1: '}|
{E:=' expected near '<eof>'} |
{9:E5115: Loading Lua debug string: (debug command):1: '}|
{9:=' expected near '<eof>'} |
lua_debug> ^ |
]])
feed('cont<cr>') -- exactly "cont", exit now
screen:expect([[
|
{0:~ }|*6
{1: }|
{1:~ }|*6
{3: }|
lua_debug> conttt |
{E:E5115: Loading Lua debug string: (debug command):1: '}|
{E:=' expected near '<eof>'} |
{9:E5115: Loading Lua debug string: (debug command):1: '}|
{9:=' expected near '<eof>'} |
lua_debug> cont |
x |
{cr:Press ENTER or type command to continue}^ |
{6:Press ENTER or type command to continue}^ |
]])
feed('<cr>')
screen:expect {
grid = [[
^ |
{0:~ }|*12
{1:~ }|*12
|
]],
}

View File

@@ -51,13 +51,6 @@ describe('vim.secure', function()
end)
it('regular file', function()
screen:set_default_attr_ids({
[1] = { bold = true, foreground = Screen.colors.Blue1 },
[2] = { bold = true, reverse = true },
[3] = { bold = true, foreground = Screen.colors.SeaGreen },
[4] = { reverse = true },
})
local cwd = fn.getcwd()
local msg = 'exrc: Found untrusted code. To enable it, choose (v)iew then run `:trust`:'
local path = vim.fs.joinpath(cwd, 'Xfile')
@@ -67,11 +60,11 @@ describe('vim.secure', function()
screen:expect([[
{MATCH: +}|
{1:~{MATCH: +}}|*2
{2:{MATCH: +}}|
{3:{MATCH: +}}|
:lua vim.secure.read('Xfile'){MATCH: +}|
{3:]] .. msg .. [[}{MATCH: *}|
{3:]] .. path .. [[}{MATCH: *}|
{3:[i]gnore, (v)iew, (d)eny: }^{MATCH: +}|
{6:]] .. msg .. [[}{MATCH: *}|
{6:]] .. path .. [[}{MATCH: *}|
{6:[i]gnore, (v)iew, (d)eny: }^{MATCH: +}|
]])
feed('d')
screen:expect([[
@@ -89,21 +82,21 @@ describe('vim.secure', function()
screen:expect([[
{MATCH: +}|
{1:~{MATCH: +}}|*2
{2:{MATCH: +}}|
{3:{MATCH: +}}|
:lua vim.secure.read('Xfile'){MATCH: +}|
{3:]] .. msg .. [[}{MATCH: *}|
{3:]] .. path .. [[}{MATCH: *}|
{3:[i]gnore, (v)iew, (d)eny: }^{MATCH: +}|
{6:]] .. msg .. [[}{MATCH: *}|
{6:]] .. path .. [[}{MATCH: *}|
{6:[i]gnore, (v)iew, (d)eny: }^{MATCH: +}|
]])
feed('v')
feed(':trust<CR>')
screen:expect([[
^let g:foobar = 42{MATCH: +}|
{1:~{MATCH: +}}|*2
{2:]] .. vim.fs.joinpath(fn.fnamemodify(cwd, ':~'), 'Xfile') .. [[ [RO]{MATCH: +}}|
{3:]] .. vim.fs.joinpath(fn.fnamemodify(cwd, ':~'), 'Xfile') .. [[ [RO]{MATCH: +}}|
{MATCH: +}|
{1:~{MATCH: +}}|
{4:[No Name]{MATCH: +}}|
{2:[No Name]{MATCH: +}}|
Allowed in trust database: "]] .. vim.fs.joinpath(cwd, 'Xfile') .. [["{MATCH: +}|
]])
-- close the split for the next test below.
@@ -119,11 +112,11 @@ describe('vim.secure', function()
screen:expect([[
{MATCH: +}|
{1:~{MATCH: +}}|*2
{2:{MATCH: +}}|
{3:{MATCH: +}}|
:lua vim.secure.read('Xfile'){MATCH: +}|
{3:]] .. msg .. [[}{MATCH: *}|
{3:]] .. path .. [[}{MATCH: *}|
{3:[i]gnore, (v)iew, (d)eny: }^{MATCH: +}|
{6:]] .. msg .. [[}{MATCH: *}|
{6:]] .. path .. [[}{MATCH: *}|
{6:[i]gnore, (v)iew, (d)eny: }^{MATCH: +}|
]])
feed('i')
screen:expect([[
@@ -139,20 +132,20 @@ describe('vim.secure', function()
screen:expect([[
{MATCH: +}|
{1:~{MATCH: +}}|*2
{2:{MATCH: +}}|
{3:{MATCH: +}}|
:lua vim.secure.read('Xfile'){MATCH: +}|
{3:]] .. msg .. [[}{MATCH: +}|
{3:]] .. path .. [[}{MATCH: *}|
{3:[i]gnore, (v)iew, (d)eny: }^{MATCH: +}|
{6:]] .. msg .. [[}{MATCH: +}|
{6:]] .. path .. [[}{MATCH: *}|
{6:[i]gnore, (v)iew, (d)eny: }^{MATCH: +}|
]])
feed('v')
screen:expect([[
^let g:foobar = 42{MATCH: +}|
{1:~{MATCH: +}}|*2
{2:]] .. vim.fs.joinpath(fn.fnamemodify(cwd, ':~'), 'Xfile') .. [[ [RO]{MATCH: +}}|
{3:]] .. vim.fs.joinpath(fn.fnamemodify(cwd, ':~'), 'Xfile') .. [[ [RO]{MATCH: +}}|
{MATCH: +}|
{1:~{MATCH: +}}|
{4:[No Name]{MATCH: +}}|
{2:[No Name]{MATCH: +}}|
{MATCH: +}|
]])
@@ -165,13 +158,6 @@ describe('vim.secure', function()
end)
it('directory', function()
screen:set_default_attr_ids({
[1] = { bold = true, foreground = Screen.colors.Blue1 },
[2] = { bold = true, reverse = true },
[3] = { bold = true, foreground = Screen.colors.SeaGreen },
[4] = { reverse = true },
})
local cwd = fn.getcwd()
local msg =
'exrc: Found untrusted code. DIRECTORY trust is decided only by name, not contents:'
@@ -182,11 +168,11 @@ describe('vim.secure', function()
screen:expect([[
{MATCH: +}|
{1:~{MATCH: +}}|*2
{2:{MATCH: +}}|
{3:{MATCH: +}}|
:lua vim.secure.read('Xdir'){MATCH: +}|
{3:]] .. msg .. [[}{MATCH: +}|
{3:]] .. path .. [[}{MATCH: +}|
{3:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}|
{6:]] .. msg .. [[}{MATCH: +}|
{6:]] .. path .. [[}{MATCH: +}|
{6:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}|
]])
feed('d')
screen:expect([[
@@ -204,11 +190,11 @@ describe('vim.secure', function()
screen:expect([[
{MATCH: +}|
{1:~{MATCH: +}}|*2
{2:{MATCH: +}}|
{3:{MATCH: +}}|
:lua vim.secure.read('Xdir'){MATCH: +}|
{3:]] .. msg .. [[}{MATCH: +}|
{3:]] .. path .. [[}{MATCH: +}|
{3:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}|
{6:]] .. msg .. [[}{MATCH: +}|
{6:]] .. path .. [[}{MATCH: +}|
{6:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}|
]])
feed('a')
screen:expect([[
@@ -228,11 +214,11 @@ describe('vim.secure', function()
screen:expect([[
{MATCH: +}|
{1:~{MATCH: +}}|*2
{2:{MATCH: +}}|
{3:{MATCH: +}}|
:lua vim.secure.read('Xdir'){MATCH: +}|
{3:]] .. msg .. [[}{MATCH: +}|
{3:]] .. path .. [[}{MATCH: +}|
{3:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}|
{6:]] .. msg .. [[}{MATCH: +}|
{6:]] .. path .. [[}{MATCH: +}|
{6:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}|
]])
feed('i')
screen:expect([[
@@ -248,20 +234,20 @@ describe('vim.secure', function()
screen:expect([[
{MATCH: +}|
{1:~{MATCH: +}}|*2
{2:{MATCH: +}}|
{3:{MATCH: +}}|
:lua vim.secure.read('Xdir'){MATCH: +}|
{3:]] .. msg .. [[}{MATCH: +}|
{3:]] .. path .. [[}{MATCH: +}|
{3:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}|
{6:]] .. msg .. [[}{MATCH: +}|
{6:]] .. path .. [[}{MATCH: +}|
{6:[i]gnore, (v)iew, (d)eny, (a)llow: }^{MATCH: +}|
]])
feed('v')
screen:expect([[
^{MATCH: +}|
{1:~{MATCH: +}}|*2
{2:]] .. vim.fs.joinpath(fn.fnamemodify(cwd, ':~'), 'Xdir') .. [[ [RO]{MATCH: +}}|
{3:]] .. vim.fs.joinpath(fn.fnamemodify(cwd, ':~'), 'Xdir') .. [[ [RO]{MATCH: +}}|
{MATCH: +}|
{1:~{MATCH: +}}|
{4:[No Name]{MATCH: +}}|
{2:[No Name]{MATCH: +}}|
{MATCH: +}|
]])

View File

@@ -65,13 +65,6 @@ describe('vim.uv', function()
it('is API safe', function()
local screen = Screen.new(50, 10)
screen:set_default_attr_ids({
[1] = { bold = true, foreground = Screen.colors.Blue1 },
[2] = { bold = true, reverse = true },
[3] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red },
[4] = { bold = true, foreground = Screen.colors.SeaGreen4 },
[5] = { bold = true },
})
-- deferred API functions are disabled, as their safety can't be guaranteed
exec_lua([[
@@ -86,15 +79,15 @@ describe('vim.uv', function()
screen:expect([[
|
{2: }|
{3:Lua callback:} |
{3:[string "<nvim>"]:5: E5560: nvim_set_var must not }|
{3:be called in a fast event context} |
{3:stack traceback:} |
{3: [C]: in function 'nvim_set_var'} |
{3: [string "<nvim>"]:5: in function <[string }|
{3:"<nvim>"]:2>} |
{4:Press ENTER or type command to continue}^ |
{3: }|
{9:Lua callback:} |
{9:[string "<nvim>"]:5: E5560: nvim_set_var must not }|
{9:be called in a fast event context} |
{9:stack traceback:} |
{9: [C]: in function 'nvim_set_var'} |
{9: [string "<nvim>"]:5: in function <[string }|
{9:"<nvim>"]:2>} |
{6:Press ENTER or type command to continue}^ |
]])
feed('<cr>')
eq(false, eval("get(g:, 'valid', v:false)"))
@@ -151,7 +144,7 @@ describe('vim.uv', function()
end)
end)
screen:expect({ any = [[{3:Vim:E5560: Vimscript function must not be called i}]] })
screen:expect({ any = [[{9:Vim:E5560: Vimscript function must not be called i}]] })
feed('<cr>')
eq({ 1, nil }, exec_lua('return {_G.value, _G.unvalue}'))
end)

View File

@@ -1073,14 +1073,10 @@ describe('vim._with', function()
eq('', exec_capture('messages'))
local screen = Screen.new(20, 5)
screen:set_default_attr_ids {
[1] = { bold = true, reverse = true },
[2] = { bold = true, foreground = Screen.colors.Blue },
}
exec_lua [[ vim._with({ silent = true }, function() vim.cmd.echo('"ccc"') end) ]]
screen:expect [[
^ |
{2:~ }|*3
{1:~ }|*3
|
]]
end)
@@ -1229,10 +1225,6 @@ describe('vim._with', function()
it('updates ruler if cursor moved', function()
local screen = Screen.new(30, 5)
screen:set_default_attr_ids {
[1] = { reverse = true },
[2] = { bold = true, reverse = true },
}
exec_lua [[
vim.opt.ruler = true
local lines = {}
@@ -1245,9 +1237,9 @@ describe('vim._with', function()
]]
screen:expect [[
19 |
{1:< Name] [+] 20,1 3%}|
^19 |
{2:< Name] [+] 20,1 3%}|
^19 |
{3:< Name] [+] 20,1 3%}|
|
]]
exec_lua [[
@@ -1256,9 +1248,9 @@ describe('vim._with', function()
]]
screen:expect [[
99 |
{1:< Name] [+] 100,1 19%}|
{2:< Name] [+] 100,1 19%}|
^19 |
{2:< Name] [+] 20,1 3%}|
{3:< Name] [+] 20,1 3%}|
|
]]
end)

View File

@@ -125,12 +125,6 @@ static int foldLevel(linenr_T lnum)
local screen
before_each(function()
screen = Screen.new(80, 45)
screen:set_default_attr_ids({
[1] = { background = Screen.colors.Grey, foreground = Screen.colors.DarkBlue },
[2] = { bold = true, foreground = Screen.colors.Blue1 },
[3] = { bold = true, reverse = true },
[4] = { reverse = true },
})
command([[set foldexpr=v:lua.vim.lsp.foldexpr()]])
command([[split]])
end)
@@ -192,51 +186,51 @@ static int foldLevel(linenr_T lnum)
it('updates folds in all windows', function()
screen:expect({
grid = [[
{1:-}// foldLevel() {{{2 |
{1:│}/// @return fold level at line number "lnum" in the current window. |
{1: }static int foldLevel(linenr_T lnum) |
{1:-}{ |
{1:-} // While updating the folds lines between invalid_top and invalid_bot have |
{1:2} // an undefined fold level. Otherwise update the folds first. |
{1:-} if (invalid_top == 0) { |
{1:2} checkupdate(curwin); |
{1:-} } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{1:2} return prev_lnum_lvl; |
{1:-} } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{1:2} return -1; |
{1:│} } |
{1:│} |
{1:│} // Return quickly when there is no folding at all in this window. |
{1:-} if (!hasAnyFolding(curwin)) { |
{1:2} return 0; |
{1:│} } |
{1:│} |
{1:│} return foldLevelWin(curwin, lnum); |
{1: }^} |
{3:[No Name] [+] }|
{1:-}// foldLevel() {{{2 |
{1:│}/// @return fold level at line number "lnum" in the current window. |
{1: }static int foldLevel(linenr_T lnum) |
{1:-}{ |
{1:-} // While updating the folds lines between invalid_top and invalid_bot have |
{1:2} // an undefined fold level. Otherwise update the folds first. |
{1:-} if (invalid_top == 0) { |
{1:2} checkupdate(curwin); |
{1:-} } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{1:2} return prev_lnum_lvl; |
{1:-} } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{1:2} return -1; |
{1:│} } |
{1:│} |
{1:│} // Return quickly when there is no folding at all in this window. |
{1:-} if (!hasAnyFolding(curwin)) { |
{1:2} return 0; |
{1:│} } |
{1:│} |
{1:│} return foldLevelWin(curwin, lnum); |
{1: }} |
{4:[No Name] [+] }|
|
{7:-}// foldLevel() {{{2 |
{7:│}/// @return fold level at line number "lnum" in the current window. |
{7: }static int foldLevel(linenr_T lnum) |
{7:-}{ |
{7:-} // While updating the folds lines between invalid_top and invalid_bot have |
{7:2} // an undefined fold level. Otherwise update the folds first. |
{7:-} if (invalid_top == 0) { |
{7:2} checkupdate(curwin); |
{7:-} } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{7:2} return prev_lnum_lvl; |
{7:-} } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{7:2} return -1; |
{7:│} } |
{7:│} |
{7:│} // Return quickly when there is no folding at all in this window. |
{7:-} if (!hasAnyFolding(curwin)) { |
{7:2} return 0; |
{7:│} } |
{7:│} |
{7:│} return foldLevelWin(curwin, lnum); |
{7: }^} |
{3:[No Name] [+] }|
{7:-}// foldLevel() {{{2 |
{7:│}/// @return fold level at line number "lnum" in the current window. |
{7: }static int foldLevel(linenr_T lnum) |
{7:-}{ |
{7:-} // While updating the folds lines between invalid_top and invalid_bot have |
{7:2} // an undefined fold level. Otherwise update the folds first. |
{7:-} if (invalid_top == 0) { |
{7:2} checkupdate(curwin); |
{7:-} } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{7:2} return prev_lnum_lvl; |
{7:-} } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{7:2} return -1; |
{7:│} } |
{7:│} |
{7:│} // Return quickly when there is no folding at all in this window. |
{7:-} if (!hasAnyFolding(curwin)) { |
{7:2} return 0; |
{7:│} } |
{7:│} |
{7:│} return foldLevelWin(curwin, lnum); |
{7: }} |
{2:[No Name] [+] }|
|
]],
})
end)
@@ -246,51 +240,51 @@ static int foldLevel(linenr_T lnum)
feed('<C-w><C-w>zx')
screen:expect({
grid = [[
{1: }// foldLevel() {{{2 |
{1: }/// @return fold level at line number "lnum" in the current window. |
{1: }static int foldLevel(linenr_T lnum) |
{1: }{ |
{1: } // While updating the folds lines between invalid_top and invalid_bot have |
{1: } // an undefined fold level. Otherwise update the folds first. |
{1: } if (invalid_top == 0) { |
{1: } checkupdate(curwin); |
{1: } } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{1: } return prev_lnum_lvl; |
{1: } } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{1: } return -1; |
{1: } } |
{1: } |
{1: } // Return quickly when there is no folding at all in this window. |
{1: } if (!hasAnyFolding(curwin)) { |
{1: } return 0; |
{1: } } |
{1: } |
{1: } return foldLevelWin(curwin, lnum); |
{1: }} |
{4:[No Name] [+] }|
{1:-}// foldLevel() {{{2 |
{1:│}/// @return fold level at line number "lnum" in the current window. |
{1: }static int foldLevel(linenr_T lnum) |
{1:-}{ |
{1:-} // While updating the folds lines between invalid_top and invalid_bot have |
{1:2} // an undefined fold level. Otherwise update the folds first. |
{1:-} if (invalid_top == 0) { |
{1:2} checkupdate(curwin); |
{1:-} } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{1:2} return prev_lnum_lvl; |
{1:-} } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{1:2} return -1; |
{1:│} } |
{1:│} |
{1:│} // Return quickly when there is no folding at all in this window. |
{1:-} if (!hasAnyFolding(curwin)) { |
{1:2} return 0; |
{1:│} } |
{1:│} |
{1:│} return foldLevelWin(curwin, lnum); |
{1: }^} |
{3:[No Name] [+] }|
|
{7: }// foldLevel() {{{2 |
{7: }/// @return fold level at line number "lnum" in the current window. |
{7: }static int foldLevel(linenr_T lnum) |
{7: }{ |
{7: } // While updating the folds lines between invalid_top and invalid_bot have |
{7: } // an undefined fold level. Otherwise update the folds first. |
{7: } if (invalid_top == 0) { |
{7: } checkupdate(curwin); |
{7: } } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{7: } return prev_lnum_lvl; |
{7: } } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{7: } return -1; |
{7: } } |
{7: } |
{7: } // Return quickly when there is no folding at all in this window. |
{7: } if (!hasAnyFolding(curwin)) { |
{7: } return 0; |
{7: } } |
{7: } |
{7: } return foldLevelWin(curwin, lnum); |
{7: }} |
{2:[No Name] [+] }|
{7:-}// foldLevel() {{{2 |
{7:│}/// @return fold level at line number "lnum" in the current window. |
{7: }static int foldLevel(linenr_T lnum) |
{7:-}{ |
{7:-} // While updating the folds lines between invalid_top and invalid_bot have |
{7:2} // an undefined fold level. Otherwise update the folds first. |
{7:-} if (invalid_top == 0) { |
{7:2} checkupdate(curwin); |
{7:-} } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{7:2} return prev_lnum_lvl; |
{7:-} } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{7:2} return -1; |
{7:│} } |
{7:│} |
{7:│} // Return quickly when there is no folding at all in this window. |
{7:-} if (!hasAnyFolding(curwin)) { |
{7:2} return 0; |
{7:│} } |
{7:│} |
{7:│} return foldLevelWin(curwin, lnum); |
{7: }^} |
{3:[No Name] [+] }|
|
]],
})
end)
@@ -299,49 +293,49 @@ static int foldLevel(linenr_T lnum)
command('1,2d')
screen:expect({
grid = [[
{1: }^static int foldLevel(linenr_T lnum) |
{1:-}{ |
{1:-} // While updating the folds lines between invalid_top and invalid_bot have |
{1:2} // an undefined fold level. Otherwise update the folds first. |
{1:-} if (invalid_top == 0) { |
{1:2} checkupdate(curwin); |
{1:-} } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{1:2} return prev_lnum_lvl; |
{1:-} } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{1:2} return -1; |
{1:│} } |
{1:│} |
{1:│} // Return quickly when there is no folding at all in this window. |
{1:-} if (!hasAnyFolding(curwin)) { |
{1:2} return 0; |
{1:│} } |
{1:│} |
{1:│} return foldLevelWin(curwin, lnum); |
{1: }} |
{2:~ }|*2
{3:[No Name] [+] }|
{1: }static int foldLevel(linenr_T lnum) |
{1:-}{ |
{1:-} // While updating the folds lines between invalid_top and invalid_bot have |
{1:2} // an undefined fold level. Otherwise update the folds first. |
{1:-} if (invalid_top == 0) { |
{1:2} checkupdate(curwin); |
{1:-} } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{1:2} return prev_lnum_lvl; |
{1:-} } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{1:2} return -1; |
{1:│} } |
{1:│} |
{1:│} // Return quickly when there is no folding at all in this window. |
{1:-} if (!hasAnyFolding(curwin)) { |
{1:2} return 0; |
{1:│} } |
{1:│} |
{1:│} return foldLevelWin(curwin, lnum); |
{1: }} |
{2:~ }|*2
{4:[No Name] [+] }|
|
{7: }^static int foldLevel(linenr_T lnum) |
{7:-}{ |
{7:-} // While updating the folds lines between invalid_top and invalid_bot have |
{7:2} // an undefined fold level. Otherwise update the folds first. |
{7:-} if (invalid_top == 0) { |
{7:2} checkupdate(curwin); |
{7:-} } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{7:2} return prev_lnum_lvl; |
{7:-} } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{7:2} return -1; |
{7:│} } |
{7:│} |
{7:│} // Return quickly when there is no folding at all in this window. |
{7:-} if (!hasAnyFolding(curwin)) { |
{7:2} return 0; |
{7:│} } |
{7:│} |
{7:│} return foldLevelWin(curwin, lnum); |
{7: }} |
{1:~ }|*2
{3:[No Name] [+] }|
{7: }static int foldLevel(linenr_T lnum) |
{7:-}{ |
{7:-} // While updating the folds lines between invalid_top and invalid_bot have |
{7:2} // an undefined fold level. Otherwise update the folds first. |
{7:-} if (invalid_top == 0) { |
{7:2} checkupdate(curwin); |
{7:-} } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{7:2} return prev_lnum_lvl; |
{7:-} } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{7:2} return -1; |
{7:│} } |
{7:│} |
{7:│} // Return quickly when there is no folding at all in this window. |
{7:-} if (!hasAnyFolding(curwin)) { |
{7:2} return 0; |
{7:│} } |
{7:│} |
{7:│} return foldLevelWin(curwin, lnum); |
{7: }} |
{1:~ }|*2
{2:[No Name] [+] }|
|
]],
})
end)
@@ -352,51 +346,51 @@ static int foldLevel(linenr_T lnum)
end)
screen:expect({
grid = [[
{1: }// foldLevel() {{{2 |
{1: }/// @return fold level at line number "lnum" in the current window. |
{1: }static int foldLevel(linenr_T lnum) |
{1: }{ |
{1: } // While updating the folds lines between invalid_top and invalid_bot have |
{1: } // an undefined fold level. Otherwise update the folds first. |
{1: } if (invalid_top == 0) { |
{1: } checkupdate(curwin); |
{1: } } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{1: } return prev_lnum_lvl; |
{1: } } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{1: } return -1; |
{1: } } |
{1: } |
{1: } // Return quickly when there is no folding at all in this window. |
{1: } if (!hasAnyFolding(curwin)) { |
{1: } return 0; |
{1: } } |
{1: } |
{1: } return foldLevelWin(curwin, lnum); |
{1: }^} |
{3:[No Name] [+] }|
{1: }// foldLevel() {{{2 |
{1: }/// @return fold level at line number "lnum" in the current window. |
{1: }static int foldLevel(linenr_T lnum) |
{1: }{ |
{1: } // While updating the folds lines between invalid_top and invalid_bot have |
{1: } // an undefined fold level. Otherwise update the folds first. |
{1: } if (invalid_top == 0) { |
{1: } checkupdate(curwin); |
{1: } } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{1: } return prev_lnum_lvl; |
{1: } } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{1: } return -1; |
{1: } } |
{1: } |
{1: } // Return quickly when there is no folding at all in this window. |
{1: } if (!hasAnyFolding(curwin)) { |
{1: } return 0; |
{1: } } |
{1: } |
{1: } return foldLevelWin(curwin, lnum); |
{1: }} |
{4:[No Name] [+] }|
|
{7: }// foldLevel() {{{2 |
{7: }/// @return fold level at line number "lnum" in the current window. |
{7: }static int foldLevel(linenr_T lnum) |
{7: }{ |
{7: } // While updating the folds lines between invalid_top and invalid_bot have |
{7: } // an undefined fold level. Otherwise update the folds first. |
{7: } if (invalid_top == 0) { |
{7: } checkupdate(curwin); |
{7: } } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{7: } return prev_lnum_lvl; |
{7: } } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{7: } return -1; |
{7: } } |
{7: } |
{7: } // Return quickly when there is no folding at all in this window. |
{7: } if (!hasAnyFolding(curwin)) { |
{7: } return 0; |
{7: } } |
{7: } |
{7: } return foldLevelWin(curwin, lnum); |
{7: }^} |
{3:[No Name] [+] }|
{7: }// foldLevel() {{{2 |
{7: }/// @return fold level at line number "lnum" in the current window. |
{7: }static int foldLevel(linenr_T lnum) |
{7: }{ |
{7: } // While updating the folds lines between invalid_top and invalid_bot have |
{7: } // an undefined fold level. Otherwise update the folds first. |
{7: } if (invalid_top == 0) { |
{7: } checkupdate(curwin); |
{7: } } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{7: } return prev_lnum_lvl; |
{7: } } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{7: } return -1; |
{7: } } |
{7: } |
{7: } // Return quickly when there is no folding at all in this window. |
{7: } if (!hasAnyFolding(curwin)) { |
{7: } return 0; |
{7: } } |
{7: } |
{7: } return foldLevelWin(curwin, lnum); |
{7: }} |
{2:[No Name] [+] }|
|
]],
})
end)
@@ -408,51 +402,51 @@ static int foldLevel(linenr_T lnum)
end)
screen:expect({
grid = [[
{1:-}// foldLevel() {{{2 |
{1:│}/// @return fold level at line number "lnum" in the current window. |
{1: }static int foldLevel(linenr_T lnum) |
{1:-}{ |
{1:-} // While updating the folds lines between invalid_top and invalid_bot have |
{1:2} // an undefined fold level. Otherwise update the folds first. |
{1:-} if (invalid_top == 0) { |
{1:2} checkupdate(curwin); |
{1:-} } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{1:2} return prev_lnum_lvl; |
{1:-} } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{1:2} return -1; |
{1:│} } |
{1:│} |
{1:│} // Return quickly when there is no folding at all in this window. |
{1:-} if (!hasAnyFolding(curwin)) { |
{1:2} return 0; |
{1:│} } |
{1:│} |
{1:│} return foldLevelWin(curwin, lnum); |
{1: }^} |
{3:[No Name] [+] }|
{1:-}// foldLevel() {{{2 |
{1:│}/// @return fold level at line number "lnum" in the current window. |
{1: }static int foldLevel(linenr_T lnum) |
{1:-}{ |
{1:-} // While updating the folds lines between invalid_top and invalid_bot have |
{1:2} // an undefined fold level. Otherwise update the folds first. |
{1:-} if (invalid_top == 0) { |
{1:2} checkupdate(curwin); |
{1:-} } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{1:2} return prev_lnum_lvl; |
{1:-} } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{1:2} return -1; |
{1:│} } |
{1:│} |
{1:│} // Return quickly when there is no folding at all in this window. |
{1:-} if (!hasAnyFolding(curwin)) { |
{1:2} return 0; |
{1:│} } |
{1:│} |
{1:│} return foldLevelWin(curwin, lnum); |
{1: }} |
{4:[No Name] [+] }|
|
{7:-}// foldLevel() {{{2 |
{7:│}/// @return fold level at line number "lnum" in the current window. |
{7: }static int foldLevel(linenr_T lnum) |
{7:-}{ |
{7:-} // While updating the folds lines between invalid_top and invalid_bot have |
{7:2} // an undefined fold level. Otherwise update the folds first. |
{7:-} if (invalid_top == 0) { |
{7:2} checkupdate(curwin); |
{7:-} } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{7:2} return prev_lnum_lvl; |
{7:-} } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{7:2} return -1; |
{7:│} } |
{7:│} |
{7:│} // Return quickly when there is no folding at all in this window. |
{7:-} if (!hasAnyFolding(curwin)) { |
{7:2} return 0; |
{7:│} } |
{7:│} |
{7:│} return foldLevelWin(curwin, lnum); |
{7: }^} |
{3:[No Name] [+] }|
{7:-}// foldLevel() {{{2 |
{7:│}/// @return fold level at line number "lnum" in the current window. |
{7: }static int foldLevel(linenr_T lnum) |
{7:-}{ |
{7:-} // While updating the folds lines between invalid_top and invalid_bot have |
{7:2} // an undefined fold level. Otherwise update the folds first. |
{7:-} if (invalid_top == 0) { |
{7:2} checkupdate(curwin); |
{7:-} } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{7:2} return prev_lnum_lvl; |
{7:-} } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{7:2} return -1; |
{7:│} } |
{7:│} |
{7:│} // Return quickly when there is no folding at all in this window. |
{7:-} if (!hasAnyFolding(curwin)) { |
{7:2} return 0; |
{7:│} } |
{7:│} |
{7:│} return foldLevelWin(curwin, lnum); |
{7: }} |
{2:[No Name] [+] }|
|
]],
})
end)
@@ -463,13 +457,6 @@ static int foldLevel(linenr_T lnum)
local screen
before_each(function()
screen = Screen.new(80, 23)
screen:set_default_attr_ids({
[1] = { background = Screen.colors.Grey, foreground = Screen.colors.DarkBlue },
[2] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey },
[3] = { bold = true, foreground = Screen.colors.Blue1 },
[4] = { bold = true, reverse = true },
[5] = { reverse = true },
})
command(
[[set foldexpr=v:lua.vim.lsp.foldexpr() foldtext=v:lua.vim.lsp.foldtext() foldlevel=1]]
)
@@ -478,24 +465,24 @@ static int foldLevel(linenr_T lnum)
it('shows the first folded line if `collapsedText` does not exist', function()
screen:expect({
grid = [[
{1:-}// foldLevel() {{{2 |
{1:│}/// @return fold level at line number "lnum" in the current window. |
{1: }static int foldLevel(linenr_T lnum) |
{1:-}{ |
{1:+}{2: // While updating the folds lines between invalid_top and invalid_bot have···}|
{1:+}{2: if (invalid_top == 0) {······················································}|
{1:+}{2: } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) {························}|
{1:+}{2: } else if (lnum >= invalid_top && lnum <= invalid_bot) {·····················}|
{1:│} } |
{1:│} |
{1:│} // Return quickly when there is no folding at all in this window. |
{1:+}{2: if (!hasAnyFolding(curwin)) {················································}|
{1:│} } |
{1:│} |
{1:│} return foldLevelWin(curwin, lnum); |
{1: }^} |
{3:~ }|*6
|
{7:-}// foldLevel() {{{2 |
{7:│}/// @return fold level at line number "lnum" in the current window. |
{7: }static int foldLevel(linenr_T lnum) |
{7:-}{ |
{7:+}{13: // While updating the folds lines between invalid_top and invalid_bot have···}|
{7:+}{13: if (invalid_top == 0) {······················································}|
{7:+}{13: } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) {························}|
{7:+}{13: } else if (lnum >= invalid_top && lnum <= invalid_bot) {·····················}|
{7:│} } |
{7:│} |
{7:│} // Return quickly when there is no folding at all in this window. |
{7:+}{13: if (!hasAnyFolding(curwin)) {················································}|
{7:│} } |
{7:│} |
{7:│} return foldLevelWin(curwin, lnum); |
{7: }^} |
{1:~ }|*6
|
]],
})
end)
@@ -529,13 +516,6 @@ static int foldLevel(linenr_T lnum)
local screen
before_each(function()
screen = Screen.new(80, 23)
screen:set_default_attr_ids({
[1] = { background = Screen.colors.Grey, foreground = Screen.colors.DarkBlue },
[2] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey },
[3] = { bold = true, foreground = Screen.colors.Blue1 },
[4] = { bold = true, reverse = true },
[5] = { reverse = true },
})
command([[set foldexpr=v:lua.vim.lsp.foldexpr()]])
end)
@@ -545,27 +525,27 @@ static int foldLevel(linenr_T lnum)
end)
screen:expect({
grid = [[
{1:+}{2:+-- 2 lines: foldLevel()······················································}|
{1: }static int foldLevel(linenr_T lnum) |
{1:-}{ |
{1:+}{2:+--- 2 lines: While updating the folds lines between invalid_top and invalid_b}|
{1:-} if (invalid_top == 0) { |
{1:2} checkupdate(curwin); |
{1:-} } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{1:2} return prev_lnum_lvl; |
{1:-} } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{1:2} return -1; |
{1:│} } |
{1:│} |
{1:│} // Return quickly when there is no folding at all in this window. |
{1:-} if (!hasAnyFolding(curwin)) { |
{1:2} return 0; |
{1:│} } |
{1:│} |
{1:│} return foldLevelWin(curwin, lnum); |
{1: }^} |
{3:~ }|*3
|
{7:+}{13:+-- 2 lines: foldLevel()······················································}|
{7: }static int foldLevel(linenr_T lnum) |
{7:-}{ |
{7:+}{13:+--- 2 lines: While updating the folds lines between invalid_top and invalid_b}|
{7:-} if (invalid_top == 0) { |
{7:2} checkupdate(curwin); |
{7:-} } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{7:2} return prev_lnum_lvl; |
{7:-} } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{7:2} return -1; |
{7:│} } |
{7:│} |
{7:│} // Return quickly when there is no folding at all in this window. |
{7:-} if (!hasAnyFolding(curwin)) { |
{7:2} return 0; |
{7:│} } |
{7:│} |
{7:│} return foldLevelWin(curwin, lnum); |
{7: }^} |
{1:~ }|*3
|
]],
})
end)
@@ -576,37 +556,37 @@ static int foldLevel(linenr_T lnum)
end)
screen:expect({
grid = [[
{1:-}// foldLevel() {{{2 |
{1:│}/// @return fold level at line number "lnum" in the current window. |
{1: }static int foldLevel(linenr_T lnum) |
{1:+}{2:+-- 17 lines: {································································}|
{1: }^} |
{3:~ }|*17
|
{7:-}// foldLevel() {{{2 |
{7:│}/// @return fold level at line number "lnum" in the current window. |
{7: }static int foldLevel(linenr_T lnum) |
{7:+}{13:+-- 17 lines: {································································}|
{7: }^} |
{1:~ }|*17
|
]],
})
command('4foldopen')
screen:expect({
grid = [[
{1:-}// foldLevel() {{{2 |
{1:│}/// @return fold level at line number "lnum" in the current window. |
{1: }static int foldLevel(linenr_T lnum) |
{1:-}{ |
{1:-} // While updating the folds lines between invalid_top and invalid_bot have |
{1:2} // an undefined fold level. Otherwise update the folds first. |
{1:+}{2:+--- 2 lines: if (invalid_top == 0) {·········································}|
{1:+}{2:+--- 2 lines: } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) {···········}|
{1:+}{2:+--- 2 lines: } else if (lnum >= invalid_top && lnum <= invalid_bot) {········}|
{1:│} } |
{1:│} |
{1:│} // Return quickly when there is no folding at all in this window. |
{1:+}{2:+--- 2 lines: if (!hasAnyFolding(curwin)) {···································}|
{1:│} } |
{1:│} |
{1:│} return foldLevelWin(curwin, lnum); |
{1: }^} |
{3:~ }|*5
|
{7:-}// foldLevel() {{{2 |
{7:│}/// @return fold level at line number "lnum" in the current window. |
{7: }static int foldLevel(linenr_T lnum) |
{7:-}{ |
{7:-} // While updating the folds lines between invalid_top and invalid_bot have |
{7:2} // an undefined fold level. Otherwise update the folds first. |
{7:+}{13:+--- 2 lines: if (invalid_top == 0) {·········································}|
{7:+}{13:+--- 2 lines: } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) {···········}|
{7:+}{13:+--- 2 lines: } else if (lnum >= invalid_top && lnum <= invalid_bot) {········}|
{7:│} } |
{7:│} |
{7:│} // Return quickly when there is no folding at all in this window. |
{7:+}{13:+--- 2 lines: if (!hasAnyFolding(curwin)) {···································}|
{7:│} } |
{7:│} |
{7:│} return foldLevelWin(curwin, lnum); |
{7: }^} |
{1:~ }|*5
|
]],
})
end)
@@ -618,27 +598,27 @@ static int foldLevel(linenr_T lnum)
end)
screen:expect({
grid = [[
{1:+}{2:+-- 2 lines: foldLevel()······················································}|
{1: }static int foldLevel(linenr_T lnum) |
{1:-}{ |
{1:+}{2:+--- 2 lines: While updating the folds lines between invalid_top and invalid_b}|
{1:-} if (invalid_top == 0) { |
{1:2} checkupdate(curwin); |
{1:-} } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{1:2} return prev_lnum_lvl; |
{1:-} } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{1:2} return -1; |
{1:│} } |
{1:│} |
{1:│} // Return quickly when there is no folding at all in this window. |
{1:-} if (!hasAnyFolding(curwin)) { |
{1:2} return 0; |
{1:│} } |
{1:│} |
{1:│} return foldLevelWin(curwin, lnum); |
{1: }^} |
{3:~ }|*3
|
{7:+}{13:+-- 2 lines: foldLevel()······················································}|
{7: }static int foldLevel(linenr_T lnum) |
{7:-}{ |
{7:+}{13:+--- 2 lines: While updating the folds lines between invalid_top and invalid_b}|
{7:-} if (invalid_top == 0) { |
{7:2} checkupdate(curwin); |
{7:-} } else if (lnum == prev_lnum && prev_lnum_lvl >= 0) { |
{7:2} return prev_lnum_lvl; |
{7:-} } else if (lnum >= invalid_top && lnum <= invalid_bot) { |
{7:2} return -1; |
{7:│} } |
{7:│} |
{7:│} // Return quickly when there is no folding at all in this window. |
{7:-} if (!hasAnyFolding(curwin)) { |
{7:2} return 0; |
{7:│} } |
{7:│} |
{7:│} return foldLevelWin(curwin, lnum); |
{7: }^} |
{1:~ }|*3
|
]],
})
end)

View File

@@ -17,19 +17,14 @@ describe("'spell'", function()
before_each(function()
clear()
screen = Screen.new(80, 8)
screen:set_default_attr_ids({
[0] = { bold = true, foreground = Screen.colors.Blue },
[1] = { special = Screen.colors.Red, undercurl = true },
[2] = { special = Screen.colors.Blue, undercurl = true },
[3] = { foreground = tonumber('0x6a0dad') },
[4] = { foreground = Screen.colors.Magenta },
[5] = { bold = true, foreground = Screen.colors.SeaGreen },
[6] = { foreground = Screen.colors.Red },
[7] = { foreground = Screen.colors.Blue },
[8] = { foreground = Screen.colors.Blue, special = Screen.colors.Red, undercurl = true },
[9] = { bold = true },
[10] = { background = Screen.colors.LightGrey, foreground = Screen.colors.DarkBlue },
})
screen:add_extra_attr_ids {
[100] = { special = Screen.colors.Red, undercurl = true },
[101] = { special = Screen.colors.Blue, undercurl = true },
[102] = { foreground = Screen.colors.Blue, special = Screen.colors.Red, undercurl = true },
[103] = { foreground = tonumber('0x6a0dad') },
[104] = { foreground = Screen.colors.Red, underline = true },
[105] = { foreground = Screen.colors.Blue, underline = true },
}
end)
it('joins long lines #7937', function()
@@ -48,13 +43,13 @@ describe("'spell'", function()
]])
feed('ggJJJJJJ0')
screen:expect([[
{1:^Lorem} {1:ipsum} dolor sit {1:amet}, {1:consectetur} {1:adipiscing} {1:elit}, {1:sed} do {1:eiusmod} {1:tempor} {1:i}|
{1:ncididunt} {1:ut} {1:labore} et {1:dolore} {1:magna} {1:aliqua}. {1:Ut} {1:enim} ad minim {1:veniam}, {1:quis} {1:nostru}|
{1:d} {1:exercitation} {1:ullamco} {1:laboris} {1:nisi} {1:ut} {1:aliquip} ex ea {1:commodo} {1:consequat}. {1:Duis} {1:aut}|
{1:e} {1:irure} dolor in {1:reprehenderit} in {1:voluptate} {1:velit} {1:esse} {1:cillum} {1:dolore} {1:eu} {1:fugiat} {1:n}|
{1:ulla} {1:pariatur}. {1:Excepteur} {1:sint} {1:occaecat} {1:cupidatat} non {1:proident}, {1:sunt} in culpa {1:qui}|
{1:officia} {1:deserunt} {1:mollit} {1:anim} id est {1:laborum}. |
{0:~ }|
{100:^Lorem} {100:ipsum} dolor sit {100:amet}, {100:consectetur} {100:adipiscing} {100:elit}, {100:sed} do {100:eiusmod} {100:tempor} {100:i}|
{100:ncididunt} {100:ut} {100:labore} et {100:dolore} {100:magna} {100:aliqua}. {100:Ut} {100:enim} ad minim {100:veniam}, {100:quis} {100:nostru}|
{100:d} {100:exercitation} {100:ullamco} {100:laboris} {100:nisi} {100:ut} {100:aliquip} ex ea {100:commodo} {100:consequat}. {100:Duis} {100:aut}|
{100:e} {100:irure} dolor in {100:reprehenderit} in {100:voluptate} {100:velit} {100:esse} {100:cillum} {100:dolore} {100:eu} {100:fugiat} {100:n}|
{100:ulla} {100:pariatur}. {100:Excepteur} {100:sint} {100:occaecat} {100:cupidatat} non {100:proident}, {100:sunt} in culpa {100:qui}|
{100:officia} {100:deserunt} {100:mollit} {100:anim} id est {100:laborum}. |
{1:~ }|
|
]])
end)
@@ -76,10 +71,10 @@ describe("'spell'", function()
^This is some text without any spell errors. Everything |
should just be black, nothing wrong here. |
|
This line has a {1:sepll} error. {2:and} missing caps. |
{1:And and} this is {1:the the} duplication. |
{2:with} missing caps here. |
{0:~ }|
This line has a {100:sepll} error. {101:and} missing caps. |
{100:And and} this is {100:the the} duplication. |
{101:with} missing caps here. |
{1:~ }|
|
]])
end)
@@ -98,101 +93,101 @@ describe("'spell'", function()
set spell spelllang=en
]=])
screen:expect([[
^ This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. |
{2:another} missing cap here. |
^ This line has a {100:sepll} error. {101:and} missing caps and trailing spaces. |
{101:another} missing cap here. |
|
{2:and} here. |
{101:and} here. |
|
{2:and} here. |
{0:~ }|
{101:and} here. |
{1:~ }|
|
]])
-- After adding word missing Cap in next line is updated
feed('3GANot<Esc>')
screen:expect([[
This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. |
{2:another} missing cap here. |
This line has a {100:sepll} error. {101:and} missing caps and trailing spaces. |
{101:another} missing cap here. |
No^t |
and here. |
|
{2:and} here. |
{0:~ }|
{101:and} here. |
{1:~ }|
|
]])
-- Deleting a full stop removes missing Cap in next line
feed('5Gdd<C-L>k$x')
screen:expect([[
This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. |
{2:another} missing cap here. |
This line has a {100:sepll} error. {101:and} missing caps and trailing spaces. |
{101:another} missing cap here. |
Not |
and her^e |
and here. |
{0:~ }|*2
{1:~ }|*2
|
]])
-- Undo also updates the next line (go to command line to remove message)
feed('u:<Esc>')
screen:expect([[
This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. |
{2:another} missing cap here. |
This line has a {100:sepll} error. {101:and} missing caps and trailing spaces. |
{101:another} missing cap here. |
Not |
and here^. |
{2:and} here. |
{0:~ }|*2
{101:and} here. |
{1:~ }|*2
|
]])
-- Folding an empty line does not remove Cap in next line
feed('uzfk:<Esc>')
screen:expect([[
This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. |
{2:another} missing cap here. |
This line has a {100:sepll} error. {101:and} missing caps and trailing spaces. |
{101:another} missing cap here. |
Not |
{10:^+-- 2 lines: and here.·························································}|
{2:and} here. |
{0:~ }|*2
{13:^+-- 2 lines: and here.·························································}|
{101:and} here. |
{1:~ }|*2
|
]])
-- Folding the end of a sentence does not remove Cap in next line
-- and editing a line does not remove Cap in current line
feed('Jzfkk$x')
screen:expect([[
This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. |
{2:another} missing cap her^e |
{10:+-- 2 lines: Not·······························································}|
{2:and} here. |
{0:~ }|*3
This line has a {100:sepll} error. {101:and} missing caps and trailing spaces. |
{101:another} missing cap her^e |
{13:+-- 2 lines: Not·······························································}|
{101:and} here. |
{1:~ }|*3
|
]])
-- Cap is correctly applied in the first row of a window
feed('<C-E><C-L>')
screen:expect([[
{2:another} missing cap her^e |
{10:+-- 2 lines: Not·······························································}|
{2:and} here. |
{0:~ }|*4
{101:another} missing cap her^e |
{13:+-- 2 lines: Not·······························································}|
{101:and} here. |
{1:~ }|*4
|
]])
-- Adding an empty line does not remove Cap in "mod_bot" area
feed('zbO<Esc>')
screen:expect([[
This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. |
This line has a {100:sepll} error. {101:and} missing caps and trailing spaces. |
^ |
{2:another} missing cap here |
{10:+-- 2 lines: Not·······························································}|
{2:and} here. |
{0:~ }|*2
{101:another} missing cap here |
{13:+-- 2 lines: Not·······························································}|
{101:and} here. |
{1:~ }|*2
|
]])
-- Multiple empty lines does not remove Cap in the line after
feed('O<Esc><C-L>')
screen:expect([[
This line has a {1:sepll} error. {2:and} missing caps and trailing spaces. |
This line has a {100:sepll} error. {101:and} missing caps and trailing spaces. |
^ |
|
{2:another} missing cap here |
{10:+-- 2 lines: Not·······························································}|
{2:and} here. |
{0:~ }|
{101:another} missing cap here |
{13:+-- 2 lines: Not·······························································}|
{101:and} here. |
{1:~ }|
|
]])
end)
@@ -209,21 +204,21 @@ describe("'spell'", function()
]=])
feed('51|C')
screen:expect([[
{2:test} test test test test test test test test test ^test test test test test test |
{101:test} test test test test test test test test test ^test test test test test test |
test test test test$ |
|
{2:end} |
{0:~ }|*3
{9:-- INSERT --} |
{101:end} |
{1:~ }|*3
{5:-- INSERT --} |
]])
feed('x')
screen:expect([[
{2:test} test test test test test test test test test x^est test test test test test |
{101:test} test test test test test test test test test x^est test test test test test |
test test test test$ |
|
{2:end} |
{0:~ }|*3
{9:-- INSERT --} |
{101:end} |
{1:~ }|*3
{5:-- INSERT --} |
]])
end)
@@ -237,80 +232,80 @@ describe("'spell'", function()
// I am a speling mistakke]])
feed('ge')
screen:expect([[
{3:#include }{4:<stdbool.h>} |
{5:bool} func({5:void}); |
{7:// I am a }{8:spelin^g}{7: }{8:mistakke} |
{0:~ }|*4
{103:#include }{26:<stdbool.h>} |
{6:bool} func({6:void}); |
{18:// I am a }{102:spelin^g}{18: }{102:mistakke} |
{1:~ }|*4
|
]])
feed(']s')
screen:expect([[
{3:#include }{4:<stdbool.h>} |
{5:bool} func({5:void}); |
{7:// I am a }{8:speling}{7: }{8:^mistakke} |
{0:~ }|*4
{103:#include }{26:<stdbool.h>} |
{6:bool} func({6:void}); |
{18:// I am a }{102:speling}{18: }{102:^mistakke} |
{1:~ }|*4
|
]])
feed(']s')
screen:expect([[
{3:#include }{4:<stdbool.h>} |
{5:bool} func({5:void}); |
{7:// I am a }{8:^speling}{7: }{8:mistakke} |
{0:~ }|*4
{6:search hit BOTTOM, continuing at TOP} |
{103:#include }{26:<stdbool.h>} |
{6:bool} func({6:void}); |
{18:// I am a }{102:^speling}{18: }{102:mistakke} |
{1:~ }|*4
{19:search hit BOTTOM, continuing at TOP} |
]])
exec('echo ""')
local ns = api.nvim_create_namespace('spell')
-- extmark with spell=true enables spell
local id = api.nvim_buf_set_extmark(0, ns, 1, 4, { end_row = 1, end_col = 10, spell = true })
screen:expect([[
{3:#include }{4:<stdbool.h>} |
{5:bool} {1:func}({5:void}); |
{7:// I am a }{8:^speling}{7: }{8:mistakke} |
{0:~ }|*4
{103:#include }{26:<stdbool.h>} |
{6:bool} {100:func}({6:void}); |
{18:// I am a }{102:^speling}{18: }{102:mistakke} |
{1:~ }|*4
|
]])
feed('[s')
screen:expect([[
{3:#include }{4:<stdbool.h>} |
{5:bool} {1:^func}({5:void}); |
{7:// I am a }{8:speling}{7: }{8:mistakke} |
{0:~ }|*4
{103:#include }{26:<stdbool.h>} |
{6:bool} {100:^func}({6:void}); |
{18:// I am a }{102:speling}{18: }{102:mistakke} |
{1:~ }|*4
|
]])
api.nvim_buf_del_extmark(0, ns, id)
-- extmark with spell=false disables spell
id = api.nvim_buf_set_extmark(0, ns, 2, 18, { end_row = 2, end_col = 26, spell = false })
screen:expect([[
{3:#include }{4:<stdbool.h>} |
{5:bool} ^func({5:void}); |
{7:// I am a }{8:speling}{7: mistakke} |
{0:~ }|*4
{103:#include }{26:<stdbool.h>} |
{6:bool} ^func({6:void}); |
{18:// I am a }{102:speling}{18: mistakke} |
{1:~ }|*4
|
]])
feed('[s')
screen:expect([[
{3:#include }{4:<stdbool.h>} |
{5:bool} func({5:void}); |
{7:// I am a }{8:^speling}{7: mistakke} |
{0:~ }|*4
{6:search hit TOP, continuing at BOTTOM} |
{103:#include }{26:<stdbool.h>} |
{6:bool} func({6:void}); |
{18:// I am a }{102:^speling}{18: mistakke} |
{1:~ }|*4
{19:search hit TOP, continuing at BOTTOM} |
]])
exec('echo ""')
api.nvim_buf_del_extmark(0, ns, id)
screen:expect([[
{3:#include }{4:<stdbool.h>} |
{5:bool} func({5:void}); |
{7:// I am a }{8:^speling}{7: }{8:mistakke} |
{0:~ }|*4
{103:#include }{26:<stdbool.h>} |
{6:bool} func({6:void}); |
{18:// I am a }{102:^speling}{18: }{102:mistakke} |
{1:~ }|*4
|
]])
feed(']s')
screen:expect([[
{3:#include }{4:<stdbool.h>} |
{5:bool} func({5:void}); |
{7:// I am a }{8:speling}{7: }{8:^mistakke} |
{0:~ }|*4
{103:#include }{26:<stdbool.h>} |
{6:bool} func({6:void}); |
{18:// I am a }{102:speling}{18: }{102:^mistakke} |
{1:~ }|*4
|
]])
-- "noplainbuffer" shouldn't change spellchecking behavior with syntax enabled
@@ -318,10 +313,10 @@ describe("'spell'", function()
screen:expect_unchanged()
feed('[s')
screen:expect([[
{3:#include }{4:<stdbool.h>} |
{5:bool} func({5:void}); |
{7:// I am a }{8:^speling}{7: }{8:mistakke} |
{0:~ }|*4
{103:#include }{26:<stdbool.h>} |
{6:bool} func({6:void}); |
{18:// I am a }{102:^speling}{18: }{102:mistakke} |
{1:~ }|*4
|
]])
-- no spellchecking with "noplainbuffer" and syntax disabled
@@ -330,7 +325,7 @@ describe("'spell'", function()
#include <stdbool.h> |
bool func(void); |
// I am a ^speling mistakke |
{0:~ }|*4
{1:~ }|*4
|
]])
feed(']s')
@@ -338,25 +333,25 @@ describe("'spell'", function()
#include <stdbool.h> |
bool func(void); |
// I am a ^speling mistakke |
{0:~ }|*4
{6:search hit BOTTOM, continuing at TOP} |
{1:~ }|*4
{19:search hit BOTTOM, continuing at TOP} |
]])
exec('echo ""')
-- everything is spellchecked without "noplainbuffer" with syntax disabled
exec('set spelloptions&')
screen:expect([[
#include <{1:stdbool}.h> |
{1:bool} {1:func}(void); |
// I am a {1:^speling} {1:mistakke} |
{0:~ }|*4
#include <{100:stdbool}.h> |
{100:bool} {100:func}(void); |
// I am a {100:^speling} {100:mistakke} |
{1:~ }|*4
|
]])
feed('[s')
screen:expect([[
#include <{1:stdbool}.h> |
{1:bool} {1:^func}(void); |
// I am a {1:speling} {1:mistakke} |
{0:~ }|*4
#include <{100:stdbool}.h> |
{100:bool} {100:^func}(void); |
// I am a {100:speling} {100:mistakke} |
{1:~ }|*4
|
]])
end)
@@ -371,22 +366,14 @@ describe("'spell'", function()
local ns = api.nvim_create_namespace('spell')
api.nvim_buf_set_extmark(0, ns, 0, 0, { hl_group = 'WarningMsg', end_col = 43 })
screen:expect([[
{6:^This is some text without any spell errors.}|
{0:~ }|
{19:^This is some text without any spell errors.}|
{1:~ }|
|
]])
end)
it('overrides syntax when Visual selection is active', function()
screen:try_resize(43, 3)
screen:set_default_attr_ids({
[0] = { bold = true, foreground = Screen.colors.Blue },
[1] = { foreground = Screen.colors.Blue },
[2] = { foreground = Screen.colors.Red },
[3] = { foreground = Screen.colors.Blue, underline = true },
[4] = { foreground = Screen.colors.Red, underline = true },
[5] = { bold = true },
})
exec([[
hi! Comment guibg=NONE guifg=Blue gui=NONE guisp=NONE
hi! SpellBad guibg=NONE guifg=Red gui=NONE guisp=NONE
@@ -396,14 +383,14 @@ describe("'spell'", function()
set spell
]])
screen:expect([[
{1:^// Here is a }{2:misspeld}{1: word.} |
{0:~ }|
{18:^// Here is a }{19:misspeld}{18: word.} |
{1:~ }|
|
]])
feed('V')
screen:expect([[
{1:^/}{3:/ Here is a }{4:misspeld}{3: word.} |
{0:~ }|
{18:^/}{105:/ Here is a }{104:misspeld}{105: word.} |
{1:~ }|
{5:-- VISUAL LINE --} |
]])
end)
@@ -415,43 +402,43 @@ describe("'spell'", function()
exec('setglobal spelloptions=camel')
insert('Here is TheCamelWord being spellchecked')
screen:expect([[
Here is {1:TheCamelWord} being spellchecke^d |
{0:~ }|
Here is {100:TheCamelWord} being spellchecke^d |
{1:~ }|
|
]])
exec('enew')
insert('There is TheCamelWord being spellchecked')
screen:expect([[
There is TheCamelWord being spellchecke^d |
{0:~ }|
{1:~ }|
|
]])
-- :setlocal applies to current buffer but not future buffers
exec('setlocal spelloptions=')
screen:expect([[
There is {1:TheCamelWord} being spellchecke^d |
{0:~ }|
There is {100:TheCamelWord} being spellchecke^d |
{1:~ }|
|
]])
exec('enew')
insert('What is TheCamelWord being spellchecked')
screen:expect([[
What is TheCamelWord being spellchecke^d |
{0:~ }|
{1:~ }|
|
]])
-- :set applies to both current buffer and future buffers
exec('set spelloptions=')
screen:expect([[
What is {1:TheCamelWord} being spellchecke^d |
{0:~ }|
What is {100:TheCamelWord} being spellchecke^d |
{1:~ }|
|
]])
exec('enew')
insert('Where is TheCamelWord being spellchecked')
screen:expect([[
Where is {1:TheCamelWord} being spellchecke^d |
{0:~ }|
Where is {100:TheCamelWord} being spellchecke^d |
{1:~ }|
|
]])
end)
@@ -504,12 +491,12 @@ describe("'spell'", function()
})
end)
screen:expect([[
{1:^Splel} |
{1:Splle} |
{100:^Splel} |
{100:Splle} |
Sepll |
{1:Spele} |
{1:Speel} |
{0:~ }|*2
{100:Spele} |
{100:Speel} |
{1:~ }|*2
|
]])
@@ -539,12 +526,12 @@ describe("'spell'", function()
})
end)
screen:expect([[
{1:^Splel} |
{1:Splle} |
{1:Sepll} |
{1:Spele} |
{100:^Splel} |
{100:Splle} |
{100:Sepll} |
{100:Spele} |
Speel |
{0:~ }|*2
{1:~ }|*2
|
]])