From 3572319b4cb1a4163624a5fe328886f1928dbc4a Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 18 Oct 2024 11:33:12 +0100 Subject: feat(vim.validate): improve fast form and deprecate spec form Problem: `vim.validate()` takes two forms when it only needs one. Solution: - Teach the fast form all the features of the spec form. - Deprecate the spec form. - General optimizations for both forms. - Add a `message` argument which can be used alongside or in place of the `optional` argument. --- runtime/lua/vim/termcap.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'runtime/lua/vim/termcap.lua') diff --git a/runtime/lua/vim/termcap.lua b/runtime/lua/vim/termcap.lua index 1da2e71839..2c36561587 100644 --- a/runtime/lua/vim/termcap.lua +++ b/runtime/lua/vim/termcap.lua @@ -17,10 +17,8 @@ local M = {} --- otherwise. {seq} is the control sequence for the capability if found, or nil for --- boolean capabilities. function M.query(caps, cb) - vim.validate({ - caps = { caps, { 'string', 'table' } }, - cb = { cb, 'f' }, - }) + vim.validate('caps', caps, { 'string', 'table' }) + vim.validate('cb', cb, 'function') if type(caps) ~= 'table' then caps = { caps } -- cgit From 1d4ba8c1edba064421b34c1197c3470a09798218 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 31 Oct 2024 11:28:02 +0000 Subject: fix: another round of type annotation fixes --- runtime/lua/vim/termcap.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/lua/vim/termcap.lua') diff --git a/runtime/lua/vim/termcap.lua b/runtime/lua/vim/termcap.lua index 2c36561587..4aa41bba9b 100644 --- a/runtime/lua/vim/termcap.lua +++ b/runtime/lua/vim/termcap.lua @@ -38,7 +38,7 @@ function M.query(caps, cb) local k, rest = resp:match('^\027P1%+r(%x+)(.*)$') if k and rest then local cap = vim.text.hexdecode(k) - if not pending[cap] then + if not cap or not pending[cap] then -- Received a response for a capability we didn't request. This can happen if there are -- multiple concurrent XTGETTCAP requests return -- cgit