repositories / dotfiles

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
69 69 return {}
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')
72 73 local lines = {}
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'
5 5 local M = {}
7 7 local function new(content, pos, firstc, prompt, indent, level)
8 - vim.validate({
9 - content = { content, 'table' },
10 - pos = { pos, 'number' },
11 - firstc = { firstc, 'string' },
12 - prompt = { prompt, 'string' },
13 - indent = { indent, 'number' },
14 - level = { level, 'number' },
15 - })
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({
17 15 content = content,
18 16 pos = pos,

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)
192 + end
194 + local ok, err = pcall(function()
195 + format.prompt_lines('hello', 80)
196 + end)
198 + vim.validate = validate
199 + assert.is_true(ok, err)
200 + end)
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

Modified
30 30 assert.equals('', s:text())
31 31 end)
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)
38 + end
40 + local ok, err = pcall(function()
41 + state.new({}, 0, ':', '', 0, 1)
42 + end)
44 + vim.validate = validate
45 + assert.is_true(ok, err)
46 + end)
33 48 it('handles single chunk content', function()
34 49 local s = state.new({
35 50 { {}, 'only' },