From de73a219034eb0f94be0b50cc1f2414559816796 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Sun, 5 Dec 2021 18:47:52 +0100 Subject: [PATCH] tabline: Give error message, if switching buffers is not possible When using Neovim and switching to another buffer with the mouse and the current buffer is modified, Vim refuses to switch buffers rightfully, if the user has not set 'hidden' or 'autowrite' (because it is going to unload the buffer from memory). So catch this case and let the user know. Note: :b! would be another possibility, but I do not prefer using this attribute, because it is not clear what happens to the current buffer. I think it is made hidden, but I prefer to be explicit here closes #2478 --- autoload/airline/extensions/tabline/buffers.vim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autoload/airline/extensions/tabline/buffers.vim b/autoload/airline/extensions/tabline/buffers.vim index 4cf14677..1eb79f7e 100644 --- a/autoload/airline/extensions/tabline/buffers.vim +++ b/autoload/airline/extensions/tabline/buffers.vim @@ -220,7 +220,11 @@ function! airline#extensions#tabline#buffers#clickbuf(minwid, clicks, button, mo if a:clicks == 1 && a:modifiers !~# '[^ ]' if a:button is# 'l' " left button - switch to buffer - silent execute 'buffer' a:minwid + try + silent execute 'buffer' a:minwid + catch + call airline#util#warning("Cannot switch buffer, current buffer is modified! See :h 'hidden'") + endtry elseif a:button is# 'm' " middle button - delete buffer