From 88eb4db7516ee06a7556082bbc787a4266bd1e83 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 10 Apr 2022 14:49:58 +0800 Subject: [PATCH] fix(E5601): close all notify windows on QuitPre If the current windows is the last one, always get E5601: Cannot close window, only floating window would remain --- autoload/SpaceVim/api/notify.vim | 16 +++++++++++++++- autoload/SpaceVim/layers/lang/vim.vim | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/autoload/SpaceVim/api/notify.vim b/autoload/SpaceVim/api/notify.vim index c1e83b924..eea8b3876 100644 --- a/autoload/SpaceVim/api/notify.vim +++ b/autoload/SpaceVim/api/notify.vim @@ -118,7 +118,9 @@ function! s:self.close(...) abort noautocmd call self.__floating.win_close(self.border.winid, v:true) noautocmd call self.__floating.win_close(self.winid, v:true) endif - call remove(s:notifications, self.hashkey) + if has_key(s:notifications, self.hashkey) + call remove(s:notifications, self.hashkey) + endif let self.notification_width = 1 endif for hashkey in keys(s:notifications) @@ -126,6 +128,18 @@ function! s:self.close(...) abort endfor endfunction +function! s:self.close_all() abort + let self.message = [] + if self.win_is_open() + noautocmd call self.__floating.win_close(self.border.winid, v:true) + noautocmd call self.__floating.win_close(self.winid, v:true) + endif + if has_key(s:notifications, self.hashkey) + call remove(s:notifications, self.hashkey) + endif + let self.notification_width = 1 +endfunction + function! s:self.notify(msg, ...) abort call add(self.message, a:msg) let self.notification_color = get(a:000, 0, 'Normal') diff --git a/autoload/SpaceVim/layers/lang/vim.vim b/autoload/SpaceVim/layers/lang/vim.vim index 75b62d98d..d3cfd74fe 100644 --- a/autoload/SpaceVim/layers/lang/vim.vim +++ b/autoload/SpaceVim/layers/lang/vim.vim @@ -100,6 +100,7 @@ function! SpaceVim#layers#lang#vim#config() abort autocmd! autocmd BufWritePost *.vim call s:generate_doc() autocmd FileType vim set comments=sO:\"\ -,mO:\"\ \ ,eO:\"\",:\" + autocmd QuitPre * call s:NOTI.close_all() augroup END endif " if the lsp layer is enabled, we should disable default linter