Try to fix bug with hidden terminal buffers

This commit is contained in:
Alexander Rosenberg 2023-02-23 11:50:06 -08:00
parent 0c33486857
commit 7cd72735f2
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

View File

@ -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)