fix: fn.exists() typos (#34390)

Problem:  `exists()` checks should test for being equal to 1 rather than truthy, and extui check can be more restrictive.
Solution:  Adjust `exists()` guards to equal 1 and use `matchparen#CursorMoved`.
This commit is contained in:
phanium
2025-06-09 15:07:38 +08:00
committed by GitHub
parent 58d85cd03d
commit f2e60d000e
2 changed files with 2 additions and 2 deletions

View File

@@ -98,7 +98,7 @@ function M.cmdline_pos(pos)
if curpos[1] ~= M.row + 1 or curpos[2] ~= promptlen + pos then
curpos[1], curpos[2] = M.row + 1, promptlen + pos
-- Add matchparen highlighting to non-prompt part of cmdline.
if pos > 0 and fn.exists('#matchparen') then
if pos > 0 and fn.exists('#matchparen#CursorMoved') == 1 then
api.nvim_win_set_cursor(ext.wins.cmd, { curpos[1], curpos[2] - 1 })
vim._with({ win = ext.wins.cmd, wo = { eventignorewin = '' } }, function()
api.nvim_exec_autocmds('CursorMoved', {})

View File

@@ -157,7 +157,7 @@ end)
local function set_color_cb(funcname, callback_return, id)
api.nvim_set_var('id', id or '')
if id and id ~= '' and fn.exists('*' .. funcname .. 'N') then
if id and id ~= '' and fn.exists('*' .. funcname .. 'N') == 1 then
command(('let g:Nvim_color_input%s = {cmdline -> %sN(%s, cmdline)}'):format(id, funcname, id))
if callback_return then
api.nvim_set_var('callback_return' .. id, callback_return)