Skip to content

Commit

Permalink
fix: make comment ranges work (#807)
Browse files Browse the repository at this point in the history
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 <[email protected]>
Co-authored-by: Will Dean <[email protected]>
  • Loading branch information
ldelossa and wd60622 authored Jan 22, 2025
1 parent da764ce commit e20b4f0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lua/octo/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lua/octo/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit e20b4f0

Please sign in to comment.