From 79f80724f5b47cb6f515d96b5b4c176feacfb677 Mon Sep 17 00:00:00 2001 From: glepnir Date: Tue, 10 Oct 2023 14:46:29 +0800 Subject: [PATCH] close outline when last buffer delete close #1317 --- lua/lspsaga/symbol/outline.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lua/lspsaga/symbol/outline.lua b/lua/lspsaga/symbol/outline.lua index f414a554b..a8ca7ce81 100644 --- a/lua/lspsaga/symbol/outline.lua +++ b/lua/lspsaga/symbol/outline.lua @@ -192,6 +192,18 @@ function ot:parse(symbols, curline) end end api.nvim_set_option_value('modifiable', false, { buf = self.bufnr }) + api.nvim_buf_attach(self.main_buf, false, { + on_detach = function() + local data = vim.version().minor > 10 and require('lspsaga.symbol.head') + or require('lspsaga.symbol') + if vim.tbl_count(data) == 0 and api.nvim_win_is_valid(self.winid) then + vim.defer_fn(function() + api.nvim_buf_delete(self.bufnr, { force = true }) + pcall(api.nvim_win_close, self.winid, true) + end, 0) + end + end, + }) end function ot:collapse(node, curlnum)