Make url creation and opening two steps

This commit is contained in:
msc94 2023-08-26 21:51:16 +02:00
parent aeff967d39
commit 618c0a873a
2 changed files with 22 additions and 13 deletions

View file

@ -34,7 +34,7 @@ local function get_current_branch_or_commit_with_priority(priority)
end
end
function M.open_file(
function M.get_file_url(
priority,
--[[optional]]
range_start,
@ -67,12 +67,10 @@ function M.open_file(
file_page_url = file_page_url .. "#L" .. range_start .. "-L" .. range_end
end
if not utils.open_url(file_page_url) then
utils.notify("Could not open the built URL " .. file_page_url, vim.log.levels.ERROR)
end
return file_page_url
end
function M.open_repo(priority)
function M.get_repo_url(priority)
-- make sure to update the current directory
M.setup()
if M.is_no_git_origin then
@ -80,8 +78,11 @@ function M.open_repo(priority)
return
end
local url = M.repo_url .. "/tree/" .. get_current_branch_or_commit_with_priority(priority)
return url
end
function M.open_url(url)
if not utils.open_url(url) then
utils.notify("Could not open the built URL " .. url, vim.log.levels.ERROR)
end