From a62db885fd4021c7f848dac0ad322b19a7cf6470 Mon Sep 17 00:00:00 2001 From: Frantisek Stanko Date: Mon, 23 Oct 2023 09:44:27 +0200 Subject: [PATCH] fix: do not send data to closed stream (#2746) This commit fixes the following error: E5108: Error executing lua: Vim:Can't send data to closed stream stack traceback: [C]: in function 'chansend' /lua/telescope/previewers/term_previewer.lua:224: in function '_send_input' /lua/telescope/previewers/previewer.lua:85: in function 'send_input' /lua/telescope/previewers/term_previewer.lua:238: in function '_scroll_fn' /lua/telescope/previewers/previewer.lua:93: in function 'scroll_fn' /lua/telescope/actions/set.lua:249: in function 'run_replace_or_original' /lua/telescope/actions/mt.lua:65: in function 'scroll_previewer' /lua/telescope/actions/init.lua:222: in function 'run_replace_or_original' This happens when previewers.new_termopen_previewer()'s get_command() ends without pagination. --- lua/telescope/previewers/term_previewer.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/telescope/previewers/term_previewer.lua b/lua/telescope/previewers/term_previewer.lua index aa83374..6eeaa65 100644 --- a/lua/telescope/previewers/term_previewer.lua +++ b/lua/telescope/previewers/term_previewer.lua @@ -221,6 +221,10 @@ previewers.new_termopen_previewer = function(opts) local term_id = get_term_id(self) if term_id then + if not utils.job_is_running(term_id) then + return + end + vim.fn.chansend(term_id, termcode) end end