mirror of
https://github.com/neovim/neovim.git
synced 2026-01-04 02:17:09 +10:00
fix(treesitter): use metadata in :EditQuery captures #37116
Problem: When the `#offset!` directive is used with `:EditQuery`, the query does not take the offset into consideration when creating the extmark to preview the capture. Solution: Use the capture metadata to modify the node range before creating the extmark.
This commit is contained in:
@@ -597,10 +597,12 @@ local function update_editor_highlights(query_win, base_win, lang)
|
||||
end
|
||||
local root = tree:root()
|
||||
local topline, botline = vim.fn.line('w0', base_win), vim.fn.line('w$', base_win)
|
||||
for id, node in query:iter_captures(root, base_buf, topline - 1, botline) do
|
||||
for id, node, metadata in query:iter_captures(root, base_buf, topline - 1, botline) do
|
||||
local capture_name = query.captures[id]
|
||||
if capture_name == cursor_word then
|
||||
local lnum, col, end_lnum, end_col = node:range()
|
||||
local lnum, col, end_lnum, end_col =
|
||||
Range.unpack4(vim.treesitter.get_range(node, base_buf, metadata[id]))
|
||||
|
||||
api.nvim_buf_set_extmark(base_buf, edit_ns, lnum, col, {
|
||||
end_row = end_lnum,
|
||||
end_col = end_col,
|
||||
|
||||
Reference in New Issue
Block a user