Proper file_line left buffer cleaning
authorSergey Matveev <stargrave@stargrave.org>
Sat, 6 Feb 2021 11:57:46 +0000 (14:57 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sat, 6 Feb 2021 11:57:46 +0000 (14:57 +0300)
vim/.vim/plugin/file_line.vim

index 65962d2f9fc8d2c0e77aec4f1bc0c5149020032b..c1544a19c503f357efef833ae29621000ee494d2 100644 (file)
@@ -5,14 +5,18 @@ if exists("g:loaded_mein_file_line") | finish | endif
 let g:loaded_mein_file_line = 1
 
 function! s:gotoline()
+    let file = bufname("%")
+    if filereadable(file) | return | endif
     let names = matchlist(bufname("%"), '\(.\{-1,}\):\%(\(\d\+\)\%(:\(\d*\):\?\)\?\)\?$')
     if empty(names) | return | endif
     let file_name = names[1]
     let line_num = names[2] == "" ? "0" : names[2]
     let col_num = names[3] == "" ? "0" : names[3]
     if !filereadable(file_name) | return | endif
+    let nr = bufnr("%")
     exec "keepalt edit +" . line_num . " " . file_name
     exec "normal! " . col_num . "|"
+    exec "bdelete " . nr
 endfunction
 
 autocmd! BufNewFile *:* nested call s:gotoline()