Skip to content

Commit

Permalink
fix: correcting some problem with review mode (#225)
Browse files Browse the repository at this point in the history
Addresses issues where the new and old lines were not being set correctly
  • Loading branch information
ElricleNecro authored Apr 8, 2024
1 parent a659318 commit 12c4acb
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions lua/gitlab/actions/discussions/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -392,20 +392,17 @@ end
---@param node any
---@return number|nil
local function get_new_line(node)
if node.new_line == nil then
return nil
end

---@type GitlabLineRange|nil
local range = node.range
if range == nil then
if node.new_line == nil then
return nil
end
return node.new_line
end

local start_new_line, _ = common.parse_line_code(range.start.line_code)
if range.start.new_line ~= nil then
return range.start.new_line
end

local _, start_new_line = common.parse_line_code(range.start.line_code)
return start_new_line
end

Expand All @@ -414,17 +411,17 @@ end
---@param node any
---@return number|nil
local function get_old_line(node)
if node.old_line == nil then
return nil
end

---@type GitlabLineRange|nil
local range = node.range
if range == nil then
return node.old_line
end

local _, start_old_line = common.parse_line_code(range.start.line_code)
if range.start.old_line ~= nil then
return range.start.old_line
end

local start_old_line, _ = common.parse_line_code(range.start.line_code)
return start_old_line
end

Expand Down Expand Up @@ -453,15 +450,15 @@ M.jump_to_file = function(tree)
if line_number == nil then
line_number = 1
end
local bufnr = vim.fn.bufnr(root_node.filename)
local bufnr = vim.fn.bufnr(root_node.file_name)
if bufnr ~= -1 then
vim.cmd("buffer " .. bufnr)
vim.api.nvim_win_set_cursor(0, { line_number, 0 })
return
end

-- If buffer is not already open, open it
vim.cmd("edit " .. root_node.filename)
vim.cmd("edit " .. root_node.file_name)
vim.api.nvim_win_set_cursor(0, { line_number, 0 })
end

Expand Down

0 comments on commit 12c4acb

Please sign in to comment.