fix: fix window is not valid
This commit is contained in:
parent
0dca4c2007
commit
cbf47ebdaa
@ -20,11 +20,12 @@ local win_title = fn.has('nvim-0.9') == 1 and {
|
||||
-- " ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝",
|
||||
--}
|
||||
|
||||
|
||||
string.width = api.nvim_strwidth
|
||||
string.isEn = function(self)
|
||||
local char = { self:byte(1, -1) }
|
||||
for i = 1, #self do
|
||||
if char[i] > 127 then
|
||||
if char[i] > 128 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
@ -82,6 +82,7 @@ local function process()
|
||||
end
|
||||
|
||||
return function(word)
|
||||
buffer:init()
|
||||
-- TODO :online query
|
||||
-- local float = conf.float
|
||||
vim.notify([[
|
||||
|
@ -1,9 +1,10 @@
|
||||
local api = vim.api
|
||||
local conf = require('Trans').conf
|
||||
local hover = conf.hover
|
||||
local buffer = require('Trans.buffer')()
|
||||
local error_msg = conf.icon.notfound .. ' 没有找到相关的翻译'
|
||||
|
||||
local buffer = require('Trans.buffer')()
|
||||
|
||||
local node = require('Trans.node')
|
||||
local it, t, f = node.item, node.text, node.format
|
||||
|
||||
@ -375,6 +376,7 @@ return function(word)
|
||||
width = width,
|
||||
height = math.min(buffer:height(width), hover.height)
|
||||
}
|
||||
|
||||
run(function()
|
||||
win:set('wrap', true)
|
||||
handle_keymap(win, word)
|
||||
|
@ -27,7 +27,9 @@ end
|
||||
---@param option string option name
|
||||
---@param value any
|
||||
function window:set(option, value)
|
||||
api.nvim_win_set_option(self.winid, option, value)
|
||||
if self:is_valid() then
|
||||
api.nvim_win_set_option(self.winid, option, value)
|
||||
end
|
||||
end
|
||||
|
||||
---@param name string option name
|
||||
|
Loading…
x
Reference in New Issue
Block a user