Skip to content

Commit

Permalink
feat: use vim.iconv
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis6991 committed Dec 16, 2022
1 parent 947811c commit a618a4e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
3 changes: 3 additions & 0 deletions lua/gitsigns.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions lua/gitsigns/git.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions teal/gitsigns.tl
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ local attach_throttled = throttle_by_id(function(cbuf: integer, aucmd: string)

local file, commit = get_buf_path(cbuf)
local encoding = vim.bo[cbuf].fileencoding
if encoding == '' then
encoding = 'utf-8'
end

local file_dir = util.dirname(file)

Expand Down
16 changes: 11 additions & 5 deletions teal/gitsigns/git.tl
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,17 @@ function Repo:get_show_text(object: string, encoding: string): {string}, string
local stdout, stderr = self:command({'show', object}, {suppress_stderr = true})

if encoding ~= 'utf-8' then
scheduler()
for i, l in ipairs(stdout) do
-- TODO(lewis6991): How should we handle blob types?
if vim.fn.type(l) == vim.v.t_string then
stdout[i] = vim.fn.iconv(l, encoding, 'utf-8')
if vim.iconv then
for i, l in ipairs(stdout) do
stdout[i] = vim.iconv(l, encoding, 'utf-8')
end
else
scheduler()
for i, l in ipairs(stdout) do
-- vimscript will interpret strings containing NUL as blob type
if vim.fn.type(l) == vim.v.t_string then
stdout[i] = vim.fn.iconv(l, encoding, 'utf-8')
end
end
end
end
Expand Down

0 comments on commit a618a4e

Please sign in to comment.