mirror of
https://github.com/lewis6991/gitsigns.nvim
synced 2025-02-21 23:37:18 +00:00
feat: use vim.iconv
This commit is contained in:
parent
947811c7d3
commit
ee61b323e1
3
lua/gitsigns.lua
generated
3
lua/gitsigns.lua
generated
@ -222,6 +222,9 @@ local attach_throttled = throttle_by_id(function(cbuf, aucmd)
|
||||
|
||||
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)
|
||||
|
||||
|
14
lua/gitsigns/git.lua
generated
14
lua/gitsigns/git.lua
generated
@ -359,11 +359,17 @@ function Repo:get_show_text(object, encoding)
|
||||
local stdout, stderr = self:command({ 'show', object }, { suppress_stderr = true })
|
||||
|
||||
if encoding ~= 'utf-8' then
|
||||
scheduler()
|
||||
for i, l in ipairs(stdout) do
|
||||
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
|
||||
|
||||
if vim.fn.type(l) == vim.v.t_string then
|
||||
stdout[i] = vim.fn.iconv(l, encoding, 'utf-8')
|
||||
if vim.fn.type(l) == vim.v.t_string then
|
||||
stdout[i] = vim.fn.iconv(l, encoding, 'utf-8')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user