Stop the appending #L<number> when nothing is selected

This commit is contained in:
PlaiyTiziano 2023-04-08 20:25:43 +02:00
parent 8b7778d4ea
commit faf75f3e0a
3 changed files with 24 additions and 15 deletions

View file

@ -22,7 +22,12 @@ function M.setup()
M.repo_url = string.format("http://%s/%s/%s", gh.host, gh.user_or_org, gh.reponame)
end
function M.openFile(range_start, range_end)
function M.open_file(
--[[optional]]
range_start,
--[[optional]]
range_end
)
-- make sure to update the current directory
M.setup()
if M.is_no_git_origin then
@ -38,18 +43,12 @@ function M.openFile(range_start, range_end)
return
end
local lines
local file_page_url = M.repo_url .. "/blob/" .. utils.get_current_branch_or_commit() .. file_path
if range_start and range_end then
lines = "#L" .. range_start .. "-" .. "L" .. range_end
else
lines = "#L" .. utils.get_line_number_from_buf()
file_page_url = file_page_url .. "#L" .. range_start .. "-L" .. range_end
end
local current_branch_name_or_commit_hash = utils.get_current_branch_or_commit()
local file_page_url = M.repo_url .. "/blob/" .. current_branch_name_or_commit_hash .. file_path .. lines
local result = utils.open_url(file_page_url)
if result == false then