Skip to content

Commit

Permalink
feat: allow file changes with warning
Browse files Browse the repository at this point in the history
Fixes #43
  • Loading branch information
ruifm committed Dec 22, 2021
1 parent e303c45 commit 37e5b2b
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lua/gitlinker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,23 @@ local function get_buf_range_url_data(mode, user_opts)
return nil
end

local range = {}

local buf_path = buffer.get_relative_path()
if not git.has_file_changed(buf_path, rev) then
range = buffer.get_range(mode, user_opts.add_current_line_on_normal_mode)
elseif mode == "v" or user_opts.add_current_line_on_normal_mode then
if
git.has_file_changed(buf_path, rev)
and (mode == "v" or user_opts.add_current_line_on_normal_mode)
then
vim.notify(
string.format(
"No line numbers were computed because '%s' has changes",
"Computed Line numbers are probably wrong because '%s' has changes",
buf_path
),
vim.log.levels.WARN
)
end
local range = buffer.get_range(
mode,
user_opts.add_current_line_on_normal_mode
)

return vim.tbl_extend("force", repo_url_data, {
rev = rev,
Expand Down

0 comments on commit 37e5b2b

Please sign in to comment.