Fix: `searchcount` error (#1004) (#1005)

- `searchcount.lua` now checks if the resulting table from
  `vim.fn.searchcount` is empty to avoid the error.

Signed-off-by: Chris1320 <chris1320is@protonmail.com>
This commit is contained in:
Chris1320 2023-04-03 18:41:41 +08:00 committed by GitHub
parent 9170434aa1
commit c28a7427c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -20,6 +20,10 @@ function M:update_status()
end
local result = vim.fn.searchcount { maxcount = self.options.maxcount, timeout = self.options.timeout }
if next(result) == nil then
return ''
end
local denominator = math.min(result.total, result.maxcount)
return string.format('[%d/%d]', result.current, denominator)
end