(renderer) subtle bugfix
Some checks failed
NeoVim tests / code-quality (push) Failing after 1m17s

For text changes, we want to fire for any tag that the cursor is
adjacent to.
This commit is contained in:
Jonathan Apodaca 2025-08-25 21:23:57 -06:00
parent b74afdbfd5
commit 5dedfb991f
2 changed files with 16 additions and 12 deletions

View File

@ -1,9 +1,9 @@
local M = {} local M = {}
local LOG_ROOT = vim.fs.joinpath(vim.fn.stdpath 'cache', 'u.log')
--- @params name string --- @params name string
function M.file_for_name(name) function M.file_for_name(name) return vim.fs.joinpath(LOG_ROOT, name .. '.log.jsonl') end
return vim.fs.joinpath(vim.fn.stdpath 'cache', 'u.log', name .. '.log.jsonl')
end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- Logger class -- Logger class
@ -11,7 +11,6 @@ end
--- @class u.Logger --- @class u.Logger
--- @field name string --- @field name string
--- @field private fd number
local Logger = {} local Logger = {}
Logger.__index = Logger Logger.__index = Logger
M.Logger = Logger M.Logger = Logger
@ -20,10 +19,7 @@ M.Logger = Logger
function Logger.new(name) function Logger.new(name)
local file_path = M.file_for_name(name) local file_path = M.file_for_name(name)
vim.fn.mkdir(vim.fs.dirname(file_path), 'p') vim.fn.mkdir(vim.fs.dirname(file_path), 'p')
local self = setmetatable({ local self = setmetatable({ name = name }, Logger)
name = name,
fd = (vim.uv or vim.loop).fs_open(file_path, 'a', tonumber('644', 8)),
}, Logger)
return self return self
end end
@ -32,10 +28,12 @@ end
function Logger:write(level, ...) function Logger:write(level, ...)
local data = { ... } local data = { ... }
if #data == 1 then data = data[1] end if #data == 1 then data = data[1] end
(vim.uv or vim.loop).fs_write( local f = assert(io.open(M.file_for_name(self.name), 'a'), 'could not open file')
self.fd, assert(
vim.json.encode { ts = os.date(), level = level, data = data } .. '\n' f:write(vim.json.encode { ts = os.date(), level = level, data = data } .. '\n'),
'could not write to file'
) )
f:close()
end end
function Logger:trace(...) self:write('INFO', ...) end function Logger:trace(...) self:write('INFO', ...) end
@ -64,6 +62,12 @@ function M.setup()
vim.cmd.terminal('tail -f "' .. log_file_path .. '"') vim.cmd.terminal('tail -f "' .. log_file_path .. '"')
vim.cmd.startinsert() vim.cmd.startinsert()
end, { nargs = '*' }) end, { nargs = '*' })
vim.api.nvim_create_user_command(
'Logroot',
function() vim.api.nvim_echo({ { LOG_ROOT } }, false, {}) end,
{}
)
end end
return M return M

View File

@ -361,7 +361,7 @@ function Renderer:_on_text_changed() -- {{{
--- @type integer, integer --- @type integer, integer
local l, c = unpack(vim.api.nvim_win_get_cursor(0)) local l, c = unpack(vim.api.nvim_win_get_cursor(0))
l = l - 1 -- make it actually 0-based l = l - 1 -- make it actually 0-based
local pos_infos = self:get_tags_at { l, c } local pos_infos = self:get_tags_at({ l, c }, 'i')
for _, pos_info in ipairs(pos_infos) do for _, pos_info in ipairs(pos_infos) do
local extmark_inf = pos_info.extmark local extmark_inf = pos_info.extmark
local tag = pos_info.tag local tag = pos_info.tag