diff --git a/lua/navigator/codelens.lua b/lua/navigator/codelens.lua index ec991b6..703dcf4 100644 --- a/lua/navigator/codelens.lua +++ b/lua/navigator/codelens.lua @@ -97,15 +97,17 @@ function M.run_action() end local width = 40 - local data = {"  Auto Fix Apply Exit"} + local data = {"  CodeLens Action Apply Exit"} + local idx = 1 for i, lens in pairs(lenses) do if lens.range.start.line == (line - 1) then local title = lens.command.title:gsub("\r\n", "\\r\\n") title = title:gsub("\n", "\\n") - title = string.format("[%d] %s", i, title) + title = string.format("[%d] %s", idx, title) table.insert(data, title) lenses[i].display_title = title width = math.max(width, #lens.command.title) + idx = idx + 1 end end local apply = require('navigator.lspwrapper').apply_action @@ -122,24 +124,24 @@ function M.run_action() end apply(action_chosen) end - - gui.new_list_view { - items = data, - width = width + 4, - loc = "top_center", - relative = "cursor", - rawdata = true, - data = data, - on_confirm = function(pos) - log(pos) - apply_action(pos) - end, - on_move = function(pos) - log(pos) - return pos - end - } - + if #data > 0 then + gui.new_list_view { + items = data, + width = width + 4, + loc = "top_center", + relative = "cursor", + rawdata = true, + data = data, + on_confirm = function(pos) + log(pos) + apply_action(pos) + end, + on_move = function(pos) + log(pos) + return pos + end + } + end end return M diff --git a/lua/navigator/lspwrapper.lua b/lua/navigator/lspwrapper.lua index c71eb1e..a7a3e6b 100644 --- a/lua/navigator/lspwrapper.lua +++ b/lua/navigator/lspwrapper.lua @@ -319,10 +319,7 @@ end function M.apply_action(action_chosen) assert(action_chosen ~= nil, "action must not be nil") - if action_chosen == nil then - log("no match for ", action, lenses) - return - end + local bufnr = api.nvim_get_current_buf() local switch = string.format("silent b %d", bufnr) if action_chosen.edit or type(action_chosen.command) == "table" then if action_chosen.edit then