diff --git a/lua/fittencode/base.lua b/lua/fittencode/base.lua index f97e5abd..bd9f36b3 100644 --- a/lua/fittencode/base.lua +++ b/lua/fittencode/base.lua @@ -48,10 +48,11 @@ end ---@param name string ---@param hi table function M.set_hi(name, hi) + -- Neovim 0.10.0 has been released on 2024-05-16. if fn.has('nvim-0.10') == 1 then -- https://github.com/neovim/neovim/pull/25229 -- https://github.com/luozhiya/fittencode.nvim/issues/20 - -- hi.force = true + hi.force = true end hi.cterm = hi.cterm or {} api.nvim_set_hl(0, name, hi) diff --git a/lua/fittencode/engines/actions.lua b/lua/fittencode/engines/actions.lua index f2425db9..b96647f1 100644 --- a/lua/fittencode/engines/actions.lua +++ b/lua/fittencode/engines/actions.lua @@ -214,19 +214,21 @@ end ---@field start integer[] ---@field end integer[] ---@field vmode boolean ----@field region string[] +---@field region? string[] local VMODE = { ['v'] = true, ['V'] = true, [api.nvim_replace_termcodes('', true, true, true)] = true } local function make_range(buffer) local in_v = false - local region = {} + local region = nil local mode = api.nvim_get_mode().mode Log.debug('Action mode: {}', mode) if VMODE[mode] then in_v = true - region = fn.getregion(vim.fn.getpos('.'), vim.fn.getpos('v'), { type = vim.fn.mode() }) + if fn.has('nvim-0.10') == 1 then + region = fn.getregion(vim.fn.getpos('.'), vim.fn.getpos('v'), { type = vim.fn.mode() }) + end end api.nvim_feedkeys(api.nvim_replace_termcodes('', true, true, true), 'nx', false) diff --git a/lua/fittencode/prompt_providers/actions.lua b/lua/fittencode/prompt_providers/actions.lua index 107235f7..d1df8771 100644 --- a/lua/fittencode/prompt_providers/actions.lua +++ b/lua/fittencode/prompt_providers/actions.lua @@ -42,7 +42,7 @@ end local function get_range_content(buffer, range) local lines = {} if range.vmode then - lines = range.region + lines = range.region or {} else -- lines = api.nvim_buf_get_text(buffer, range.start[1] - 1, 0, range.start[1] - 1, -1, {}) local end_col = max_len(buffer, range['end'][1], range['end'][2])