Skip to content

Commit 175178e

Browse files
authored
fix(__internal) : fix slash problem in oldfiles (#3260)
* fix(__internal) : fix slash problem in oldfiles - Problems Problem with slash and backslash being mixed up is chronic issue of neovim in Windows. it makes telescope prompt perceive same path differently when it execute to oldfiles picker. some function like `nvim_buf_get_name()` or `vim.v.oldfiles` give paths which are mixed up with slash and backslash. - What it did For windows, it always needs to change slash(/) to backslash(\) when function which deal with path because entry_maker works properly only the case that path string has \ not /. - Effect 1) oldfiles picker doesn't show duplicated list 2) `defaults.path_display` configuration feature will works well at oldfiles pikcer * fix(__internal) : Repeated comments are erased
1 parent b5fd7f7 commit 175178e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lua/telescope/builtin/__internal.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,12 +532,19 @@ internal.oldfiles = function(opts)
532532
local current_file = vim.api.nvim_buf_get_name(current_buffer)
533533
local results = {}
534534

535+
if utils.iswin then -- for slash problem in windows
536+
current_file = current_file:gsub("/", "\\")
537+
end
538+
535539
if opts.include_current_session then
536540
for _, buffer in ipairs(utils.split_lines(vim.fn.execute ":buffers! t")) do
537541
local match = tonumber(string.match(buffer, "%s*(%d+)"))
538542
local open_by_lsp = string.match(buffer, "line 0$")
539543
if match and not open_by_lsp then
540544
local file = vim.api.nvim_buf_get_name(match)
545+
if utils.iswin then
546+
file = file:gsub("/", "\\")
547+
end
541548
if vim.loop.fs_stat(file) and match ~= current_buffer then
542549
table.insert(results, file)
543550
end
@@ -546,6 +553,9 @@ internal.oldfiles = function(opts)
546553
end
547554

548555
for _, file in ipairs(vim.v.oldfiles) do
556+
if utils.iswin then
557+
file = file:gsub("/", "\\")
558+
end
549559
local file_stat = vim.loop.fs_stat(file)
550560
if file_stat and file_stat.type == "file" and not vim.tbl_contains(results, file) and file ~= current_file then
551561
table.insert(results, file)

0 commit comments

Comments
 (0)