fix(encoding): preserve UTF-16/32 content in jj file reads and diffs (#122)

Use raw command output for jj file reads, add encoding-aware decode/encode
handling, preserve buffer encoding settings across revision buffers, and add
tests for BOMs, endianness, and roundtrip behavior.
This commit is contained in:
Lars Hansen
2026-06-16 18:35:27 +02:00
committed by GitHub
parent 33179e2f15
commit 6409ab0a66
5 changed files with 361 additions and 36 deletions
+5 -1
View File
@@ -168,7 +168,11 @@ diff.register_backend("codediff", {
return
end
local base_lines, base_had_eol, ok_read = file.get_file_content(revset, path)
-- Borrow the current buffer's encoding settings so the revision
-- 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
utils.notify(string.format("Could not read `%s` from `%s` for CodeDiff", path, revset), vim.log.levels.ERROR)
return