fix: know bug can't detect table key extended correctly

This commit is contained in:
JuanZoran 2023-03-29 14:03:48 +08:00
parent 29f12aa107
commit b12bef50f9
3 changed files with 23 additions and 21 deletions

View File

@ -13,3 +13,6 @@
- [x] Add Query FallBack - [x] Add Query FallBack
- [ ] Check if str is a word - [ ] Check if str is a word
- [ ] Unlimit width for sentence - [ ] Unlimit width for sentence
- default_strategy can't deal with table correctly

View File

@ -69,7 +69,7 @@ end
---Expand window [width | height] value ---Expand window [width | height] value
---@param opts ---@param opts
---|{ field: string, to: integer} ---|{ field: 'width'|'height', to: integer}
function window:smooth_expand(opts) function window:smooth_expand(opts)
local field = opts.field -- width | height local field = opts.field -- width | height
local from = api['nvim_win_get_' .. field](self.winid) local from = api['nvim_win_get_' .. field](self.winid)
@ -77,15 +77,13 @@ function window:smooth_expand(opts)
if from == to then return end if from == to then return end
local pause = Trans.util.pause local pause = Trans.util.pause
local method = api['nvim_win_set_' .. field] local method = api['nvim_win_set_' .. field]
local wrap = self:option 'wrap'
local wrap = self:option 'wrap' self:set('wrap', false)
local interval = self.animation.interval local interval = self.animation.interval or 12
for i = from + 1, to, (from < to and 1 or -1) do for i = from + 1, to, (from < to and 1 or -1) do
self:set('wrap', false)
method(self.winid, i) method(self.winid, i)
pause(interval) pause(interval)
end end

View File

@ -168,22 +168,24 @@ end
---Defer function when process done ---Defer function when process done
function M:defer() function M:defer()
self.window:set('wrap', true) Trans.util.main_loop(function()
self.buffer:set('modifiable', false) self.window:set('wrap', true)
self.buffer:set('modifiable', false)
local auto_close_events = self.opts.auto_close_events local auto_close_events = self.opts.auto_close_events
if not auto_close_events then return end if not auto_close_events then return end
vim.api.nvim_create_autocmd(auto_close_events, { vim.api.nvim_create_autocmd(auto_close_events, {
callback = function(opts) callback = function(opts)
vim.defer_fn(function() vim.defer_fn(function()
if not self.pin and vim.api.nvim_get_current_win() ~= self.window.winid then if not self.pin and vim.api.nvim_get_current_win() ~= self.window.winid then
pcall(vim.api.nvim_del_autocmd, opts.id) pcall(vim.api.nvim_del_autocmd, opts.id)
self:destroy() self:destroy()
end end
end, 0) end, 0)
end, end,
}) })
end)
end end
---Display Result in hover window ---Display Result in hover window
@ -221,7 +223,6 @@ function M:process(data)
local window = self.window local window = self.window
local lines = buffer:lines() local lines = buffer:lines()
local valid = window and window:is_valid() local valid = window and window:is_valid()
local width = local width =
valid and valid and