From f3699615e651a790cf1560dffce27e86943a279d Mon Sep 17 00:00:00 2001 From: ldelossa Date: Fri, 17 Jan 2025 12:13:24 -0500 Subject: [PATCH] fix: make comment ranges work Previous to this comment highlighting several lines and running the command "Octo comment add" would never result in a multi-line comment. This is seemingly because as soon as you enter the command line with ':' Neovim is switched back into normal mode and the "v" and "." attributes to `vim.fn.line` no longer register for the line range. Instead, we can use the explicit start and end marks for a selected range to capture the currently selected range despite being in normal mode at time of command run. Signed-off-by: ldelossa --- lua/octo/commands.lua | 2 +- lua/octo/utils.lua | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/octo/commands.lua b/lua/octo/commands.lua index 1e8bdd00..7dddde19 100644 --- a/lua/octo/commands.lua +++ b/lua/octo/commands.lua @@ -33,7 +33,7 @@ end function M.setup() vim.api.nvim_create_user_command("Octo", function(opts) require("octo.commands").octo(unpack(opts.fargs)) - end, { complete = require("octo.completion").octo_command_complete, nargs = "*" }) + end, { complete = require("octo.completion").octo_command_complete, nargs = "*", range = true }) local conf = config.values local card_commands diff --git a/lua/octo/utils.lua b/lua/octo/utils.lua index a5542aee..dc13952a 100644 --- a/lua/octo/utils.lua +++ b/lua/octo/utils.lua @@ -1570,8 +1570,8 @@ function M.get_lines_from_context(calling_context) line_number_start = vim.fn.line "." line_number_end = line_number_start elseif calling_context == "visual" then - line_number_start = vim.fn.line "v" - line_number_end = vim.fn.line "." + line_number_start = vim.fn.line "'<" + line_number_end = vim.fn.line "'>" elseif calling_context == "motion" then line_number_start = vim.fn.getpos("'[")[2] line_number_end = vim.fn.getpos("']")[2]