From 159b8b79666e17c8de0378d5c9dc1bc8c7afabcf Mon Sep 17 00:00:00 2001 From: James Trew <66286082+jamestrew@users.noreply.github.com> Date: Tue, 13 Aug 2024 21:44:42 -0400 Subject: [PATCH 1/4] fix(buffer_previewer): save state from `opt.setup` call (#3253) The merged table return from `vim.tbl_deep_extend` was not being utilized/assigned. --- lua/telescope/previewers/buffer_previewer.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/telescope/previewers/buffer_previewer.lua b/lua/telescope/previewers/buffer_previewer.lua index 72854e41a0..18f483df18 100644 --- a/lua/telescope/previewers/buffer_previewer.lua +++ b/lua/telescope/previewers/buffer_previewer.lua @@ -380,7 +380,7 @@ previewers.new_buffer_previewer = function(opts) function opts.setup(self) local state = {} if opt_setup then - vim.tbl_deep_extend("force", state, opt_setup(self)) + state = vim.tbl_deep_extend("force", state, opt_setup(self)) end return state end From 68a6d8e8a0a8276ad56dc2a5bc29a4767a8eb5da Mon Sep 17 00:00:00 2001 From: James Trew <66286082+jamestrew@users.noreply.github.com> Date: Tue, 13 Aug 2024 22:17:32 -0400 Subject: [PATCH 2/4] fix(term_previewer): save state from `opt.setup` call (#3254) The merged table return from `vim.tbl_deep_extend` was not being utilized/assigned. --- lua/telescope/previewers/term_previewer.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/telescope/previewers/term_previewer.lua b/lua/telescope/previewers/term_previewer.lua index a75fac09c6..da7d451bf3 100644 --- a/lua/telescope/previewers/term_previewer.lua +++ b/lua/telescope/previewers/term_previewer.lua @@ -161,7 +161,7 @@ previewers.new_termopen_previewer = function(opts) function opts.setup(self) local state = {} if opt_setup then - vim.tbl_deep_extend("force", state, opt_setup(self)) + state = vim.tbl_deep_extend("force", state, opt_setup(self)) end return state end From cac2494a6e558f3a21952d3f8becc348876580c6 Mon Sep 17 00:00:00 2001 From: James Trew <66286082+jamestrew@users.noreply.github.com> Date: Wed, 14 Aug 2024 21:44:40 -0400 Subject: [PATCH 3/4] fix(term_preview): bad `bat` command generation (#3256) Using `bat` would result in the command being a nested list. eg. using `:Telescope plaents` with `bat` installed ``` { "bat", { "--pager", "less -RS" }, "--style=plain", "--color=always", "--paging=always", "--", "/home/jt/projects/telescope.nvim/data/memes/planets/earth", } ``` This would cause `vim.fn.termopen` to throw an error as the command is expected to be a flat list or string. --- lua/telescope/previewers/term_previewer.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/telescope/previewers/term_previewer.lua b/lua/telescope/previewers/term_previewer.lua index da7d451bf3..56e5608dec 100644 --- a/lua/telescope/previewers/term_previewer.lua +++ b/lua/telescope/previewers/term_previewer.lua @@ -37,18 +37,18 @@ local bat_maker = function(filename, lnum, start, finish) local command = { "bat" } if lnum then - table.insert(command, { "--highlight-line", lnum }) + vim.list_extend(command, { "--highlight-line", lnum }) end if has_less then if start then - table.insert(command, { "--pager", string.format("less -RS +%s", start) }) + vim.list_extend(command, { "--pager", string.format("less -RS +%s", start) }) else - table.insert(command, { "--pager", "less -RS" }) + vim.list_extend(command, { "--pager", "less -RS" }) end else if start and finish then - table.insert(command, { "-r", string.format("%s:%s", start, finish) }) + vim.list_extend(command, { "-r", string.format("%s:%s", start, finish) }) end end From 5972437de807c3bc101565175da66a1aa4f8707a Mon Sep 17 00:00:00 2001 From: MarcusGrass <34198073+MarcusGrass@users.noreply.github.com> Date: Thu, 15 Aug 2024 03:50:24 +0200 Subject: [PATCH 4/4] fix(term_previewer): ensure terms are closed (#3225) --- lua/telescope/previewers/term_previewer.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lua/telescope/previewers/term_previewer.lua b/lua/telescope/previewers/term_previewer.lua index 56e5608dec..bf6f40c85a 100644 --- a/lua/telescope/previewers/term_previewer.lua +++ b/lua/telescope/previewers/term_previewer.lua @@ -102,9 +102,6 @@ local get_maker = function(opts) return maker end --- TODO: We shoudl make sure that all our terminals close all the way. --- Otherwise it could be bad if they're just sitting around, waiting to be closed. --- I don't think that's the problem, but it could be? previewers.new_termopen_previewer = function(opts) opts = opts or {} @@ -192,7 +189,7 @@ previewers.new_termopen_previewer = function(opts) local prev_bufnr = get_bufnr_by_bufentry(self, entry) if prev_bufnr then - self.state.termopen_bufnr = prev_bufnr + set_bufnr(self, prev_bufnr) utils.win_set_buf_noautocmd(preview_winid, self.state.termopen_bufnr) self.state.termopen_id = term_ids[self.state.termopen_bufnr] else