From 7cd72735f2c61bcad4564a4cf9609f563e7713c3 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Thu, 23 Feb 2023 11:50:06 -0800 Subject: [PATCH] Try to fix bug with hidden terminal buffers --- fnl/plugin/telescope.fnl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fnl/plugin/telescope.fnl b/fnl/plugin/telescope.fnl index 4cb36fa..ecf4480 100644 --- a/fnl/plugin/telescope.fnl +++ b/fnl/plugin/telescope.fnl @@ -33,11 +33,13 @@ (var last_id 0) (var terms [ ]) (each [_ id (pairs (vim.api.nvim_list_bufs))] - (let [name (vim.api.nvim_buf_get_name id)] - (when (vim.startswith name "term://") - (table.insert terms name) - (set term_count (+ term_count 1)) - (set last_id id)))) + (when (and (vim.api.nvim_buf_is_loaded id) + (vim.api.nvim_buf_get_option id :buflisted)) + (let [name (vim.api.nvim_buf_get_name id)] + (when (vim.startswith name "term://") + (table.insert terms name) + (set term_count (+ term_count 1)) + (set last_id id))))) (if (= term_count 0) (vim.cmd.terminal) (= term_count 1)