From 09b0d87b9f99d37c3e4b64be20389f6797898cf5 Mon Sep 17 00:00:00 2001 From: "A. Schueler" Date: Sun, 24 Oct 2021 08:22:56 +0200 Subject: [PATCH] fix: Exclude unlisted lsp buffers in oldfiles picker (#1219) Files opened by LSPs are listed with a trailing `line 0` instead of a date like files opened by the user. Use this behavior to filter out buffers that should not be displayed in oldfiles. --- lua/telescope/builtin/internal.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/telescope/builtin/internal.lua b/lua/telescope/builtin/internal.lua index 079b655..f95e0e5 100644 --- a/lua/telescope/builtin/internal.lua +++ b/lua/telescope/builtin/internal.lua @@ -373,7 +373,8 @@ internal.oldfiles = function(opts) if opts.include_current_session then for _, buffer in ipairs(vim.split(vim.fn.execute ":buffers! t", "\n")) do local match = tonumber(string.match(buffer, "%s*(%d+)")) - if match then + 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 vim.loop.fs_stat(file) and match ~= current_buffer then table.insert(results, file)