dotfiles
bugabingas dorkfiles
owned by bugabinga
fix neovim cmdline validation
93c65cbff8bd7ea9e10596887b8b2319817ed0a9
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
Browse filesCompare with HEAD
Changed files (4)
neovim/lua/bugabinga/cmdline/format.lua
Modified 68 68 if not prompt
or prompt
== '' then 71 - vim.validate({
prompt = { prompt,
'string' },
max_width = { max_width,
'number' } })
71 + vim.validate(
'prompt', prompt,
'string')
72 + vim.validate(
'max_width', max_width,
'number')
73 74 for line
in (prompt
.. '\n'):gmatch(
'([^\n]*)\n')
do 74 75 table.
insert(lines, line)
neovim/lua/bugabinga/cmdline/state.lua
Modified 3 3 local table = require 'std.table' 7 7 local function new(content, pos, firstc, prompt, indent, level)
9 - content = { content,
'table' },
10 - pos = { pos,
'number' },
11 - firstc = { firstc,
'string' },
12 - prompt = { prompt,
'string' },
13 - indent = { indent,
'number' },
14 - level = { level,
'number' },
8 + vim.validate(
'content', content,
'table')
9 + vim.validate(
'pos', pos,
'number')
10 + vim.validate(
'firstc', firstc,
'string')
11 + vim.validate(
'prompt', prompt,
'string')
12 + vim.validate(
'indent', indent,
'number')
13 + vim.validate(
'level', level,
'number')
16 14 return setmetatable({
neovim/tests/bugabinga/cmdline/format_spec.lua
Modified 187 + it(
'uses non-deprecated validation signature',
function()
188 + local validate
= vim.validate
189 + vim.
validate = function(name, value, validator, optional_or_msg)
190 + assert.equals(
'string',
type(name))
191 + return validate(name, value, validator, optional_or_msg)
194 + local ok, err
= pcall(
function()
195 + format.prompt_lines(
'hello',
80)
198 + vim.validate
= validate
199 + assert.is_true(ok, err)
187 202 it(
'no wrapping when prompt shorter than max_width',
function()
188 203 local result
= format.prompt_lines(
'short',
80)
189 204 assert.equals(
1,
#result)
neovim/tests/bugabinga/cmdline/state_spec.lua
Modified30 30 assert.equals(
'', s:text())
33 + it(
'uses non-deprecated validation signature',
function()
34 + local validate
= vim.validate
35 + vim.
validate = function(name, value, validator, optional_or_msg)
36 + assert.equals(
'string',
type(name))
37 + return validate(name, value, validator, optional_or_msg)
40 + local ok, err
= pcall(
function()
41 + state.new({},
0,
':',
'',
0,
1)
44 + vim.validate
= validate
45 + assert.is_true(ok, err)
33 48 it(
'handles single chunk content',
function()
34 49 local s
= state.new({