From 150fab01a9e9eb61061bf145998b608c5c9c470e Mon Sep 17 00:00:00 2001 From: lvying6 Date: Tue, 14 Jul 2020 16:43:33 +0800 Subject: [PATCH] vim: fix garbled characters display when file name matches warning or error in tar file Reference: https://github.com/vim/vim/issues/6425 The problem is, the tar.vim plugin checks if the last line matches warning or error or a few other keywords and if it does, it aborts. Signed-off-by: lvying6 --- runtime/autoload/tar.vim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/runtime/autoload/tar.vim b/runtime/autoload/tar.vim index dc670db..168a2f1 100644 --- a/runtime/autoload/tar.vim +++ b/runtime/autoload/tar.vim @@ -184,7 +184,12 @@ fun! tar#Browse(tarfile) " call Dret("tar#Browse : a:tarfile<".a:tarfile.">") return endif - if line("$") == curlast || ( line("$") == (curlast + 1) && getline("$") =~ '\c\%(warning\|error\|inappropriate\|unrecognized\)') + " If there was an error message, the last line probably matches some keywords but + " should also contain whitespace for readability. Make sure not to match a + " filename that contains the keyword (error/warning/unrecognized/inappropriate, etc) + if line("$") == curlast || ( line("$") == (curlast + 1) && + \ getline("$") =~# '\c\<\%(warning\|error\|inappropriate\|unrecognized\)\>' && + \ getline("$") =~ '\s' ) redraw! echohl WarningMsg | echo "***warning*** (tar#Browse) ".a:tarfile." doesn't appear to be a tar file" | echohl None keepj sil! %d -- 1.8.3.1