fix(live_grep/grep_string): support non-utf8 patterns (#2570)

This commit is contained in:
James Trew
2023-06-21 17:25:35 -04:00
committed by GitHub
parent 00cf15074a
commit ffe35cb433
2 changed files with 9 additions and 2 deletions

View File

@@ -126,6 +126,10 @@ files.live_grep = function(opts)
end
end
if opts.file_encoding then
additional_args[#additional_args + 1] = "--encoding=" .. opts.file_encoding
end
local args = flatten { vimgrep_arguments, additional_args }
opts.__inverted, opts.__matches = opts_contain_invert(args)
@@ -187,6 +191,10 @@ files.grep_string = function(opts)
end
end
if opts.file_encoding then
additional_args[#additional_args + 1] = "--encoding=" .. opts.file_encoding
end
if search == "" then
search = { "-v", "--", "^[[:space:]]*$" }
else

View File

@@ -326,10 +326,9 @@ do
end
end
local text = opts.file_encoding and vim.iconv(entry.text, opts.file_encoding, "utf8") or entry.text
local display, hl_group, icon = utils.transform_devicons(
entry.filename,
string.format(display_string, display_filename, coordinates, text),
string.format(display_string, display_filename, coordinates, entry.text),
disable_devicons
)