From ffe35cb433192fcb5080b557c1aef14d37092035 Mon Sep 17 00:00:00 2001 From: James Trew <66286082+jamestrew@users.noreply.github.com> Date: Wed, 21 Jun 2023 17:25:35 -0400 Subject: [PATCH] fix(live_grep/grep_string): support non-utf8 patterns (#2570) --- lua/telescope/builtin/__files.lua | 8 ++++++++ lua/telescope/make_entry.lua | 3 +-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lua/telescope/builtin/__files.lua b/lua/telescope/builtin/__files.lua index 1a1757d..339ede6 100644 --- a/lua/telescope/builtin/__files.lua +++ b/lua/telescope/builtin/__files.lua @@ -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 diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index 690db65..68af228 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -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 )