mirror of
https://github.com/zoriya/jj.nvim.git
synced 2026-08-05 02:36:07 +00:00
fix(file): show files added since the diffed revision as empty instead of erroring (#130)
Co-authored-by: Roman Konoval <roman@jiko.io>
This commit is contained in:
co-authored by
Roman Konoval
parent
cffc74128a
commit
ca6d751de6
@@ -172,8 +172,10 @@ diff.register_backend("codediff", {
|
||||
-- side is decoded in the same way as the current file.
|
||||
-- Assumes the encoding didn't change between revisions.
|
||||
local enc = file.get_buf_encoding(0)
|
||||
local base_lines, base_had_eol, ok_read = file.get_file_content(revset, path, enc)
|
||||
if not ok_read then
|
||||
-- A file added since `revset` has no content there; show it as empty
|
||||
-- so it diffs as fully added rather than aborting the diff.
|
||||
local base_lines, base_had_eol, ok_read, _, absent = file.get_file_content(revset, path, enc)
|
||||
if not ok_read and not absent then
|
||||
utils.notify(string.format("Could not read `%s` from `%s` for CodeDiff", path, revset), vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -28,8 +28,10 @@ local function open_revision(rev, path, enc)
|
||||
return
|
||||
end
|
||||
|
||||
local lines, had_eol, ok_read, used_enc = file.get_file_content(change_id, rel_path, enc)
|
||||
if not ok_read then
|
||||
-- A file added since `rev` has no content there; show it as empty so it
|
||||
-- diffs as fully added rather than aborting the diff.
|
||||
local lines, had_eol, ok_read, used_enc, absent = file.get_file_content(change_id, rel_path, enc)
|
||||
if not ok_read and not absent then
|
||||
utils.notify(string.format("Could not read `%s` from `%s`", rel_path, change_id), vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user