From f1e225cba9243597c360829a948a1fe1b457cd31 Mon Sep 17 00:00:00 2001 From: Jonathan Apodaca Date: Sat, 13 Sep 2025 08:36:33 -0600 Subject: [PATCH] do not check sub-modes in get_tags_at cull test-dependency --- .busted | 2 +- lua/u/renderer.lua | 25 ++++++++++++++++--------- shell.nix | 1 - 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.busted b/.busted index 8c64018..cf1bdf9 100644 --- a/.busted +++ b/.busted @@ -2,7 +2,7 @@ return { _all = { coverage = false, lpath = "lua/?.lua;lua/?/init.lua", - lua = "nlua", + lua = "nvim -u NONE -i NONE -l", }, default = { verbose = true diff --git a/lua/u/renderer.lua b/lua/u/renderer.lua index e644a54..73abb8c 100644 --- a/lua/u/renderer.lua +++ b/lua/u/renderer.lua @@ -340,7 +340,9 @@ function Renderer:_expr_map_callback(mode, lhs) -- {{{ -- find the tag with the smallest intersection that contains the cursor: local pos0 = vim.api.nvim_win_get_cursor(0) pos0[1] = pos0[1] - 1 -- make it actually 0-based + log('_expr_map_callback: pos0:', pos0) local pos_infos = self:get_tags_at(pos0) + log('_expr_map_callback: pos_infos:', pos_infos) if #pos_infos == 0 then return lhs end @@ -538,21 +540,26 @@ end -- }}} function Renderer:get_tags_at(pos0, mode) -- {{{ local cursor_line0, cursor_col0 = pos0[1], pos0[2] if not mode then mode = vim.api.nvim_get_mode().mode end + mode = mode:sub(1, 1) -- we don't care about sub-modes + + local raw_overlapping_extmarks = vim.api.nvim_buf_get_extmarks( + self.bufnr, + self.ns, + pos0, + pos0, + { details = true, overlap = true } + ) + log( + 'get_tags_at: context:', + { pos0 = pos0, mode = mode, raw_overlapping_extmarks = raw_overlapping_extmarks } + ) -- The cursor (block) occupies **two** extmark spaces: one for it's left -- edge, and one for it's right. We need to do our own intersection test, -- because the NeoVim API is over-inclusive in what it returns: --- @type u.renderer.RendererExtmark[] local mapped_extmarks = vim - .iter( - vim.api.nvim_buf_get_extmarks( - self.bufnr, - self.ns, - pos0, - pos0, - { details = true, overlap = true } - ) - ) + .iter(raw_overlapping_extmarks) --- @return u.renderer.RendererExtmark :map(function(ext) --- @type number, number, number, { end_row?: number; end_col?: number }|nil diff --git a/shell.nix b/shell.nix index d172772..7c2615f 100644 --- a/shell.nix +++ b/shell.nix @@ -16,7 +16,6 @@ pkgs.mkShell { pkgs.lua51Packages.busted pkgs.lua51Packages.luacov pkgs.lua51Packages.luarocks - pkgs.lua51Packages.nlua pkgs.neovim pkgs.stylua pkgs.watchexec