Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lua/telescope/builtin/__internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -532,12 +532,19 @@ internal.oldfiles = function(opts)
local current_file = vim.api.nvim_buf_get_name(current_buffer)
local results = {}

if utils.iswin then -- for slash problem in windows
current_file = current_file:gsub("/", "\\")
end

if opts.include_current_session then
for _, buffer in ipairs(utils.split_lines(vim.fn.execute ":buffers! t")) do
local match = tonumber(string.match(buffer, "%s*(%d+)"))
local open_by_lsp = string.match(buffer, "line 0$")
if match and not open_by_lsp then
local file = vim.api.nvim_buf_get_name(match)
if utils.iswin then
file = file:gsub("/", "\\")
end
if vim.loop.fs_stat(file) and match ~= current_buffer then
table.insert(results, file)
end
Expand All @@ -546,6 +553,9 @@ internal.oldfiles = function(opts)
end

for _, file in ipairs(vim.v.oldfiles) do
if utils.iswin then
file = file:gsub("/", "\\")
end
local file_stat = vim.loop.fs_stat(file)
if file_stat and file_stat.type == "file" and not vim.tbl_contains(results, file) and file ~= current_file then
table.insert(results, file)
Expand Down