From 7dbb349fd79d25e7bca5acf8fd90c8281e697bfe Mon Sep 17 00:00:00 2001 From: Boris Serebrov Date: Fri, 28 Jun 2024 19:01:13 -0400 Subject: [PATCH] This fixes search after using VinegarUp (the - key). Recently it does not always work. Sometimes pressing "-" opens the parent directory with the cursor on the first line instead of the current file line. The actual problem is that the alternative buffer name is empty after going to the netrw buffer and `expand('#:t')` returns empty string. This change fixes it by saving the curren file name before opening the netrw buffer. Note that underlying issue is not solved: the alternative buffer is still empty, so Ctrl-6 to go back still does not work. Related to https://github.com/tpope/vim-vinegar/issues/136 --- plugin/vinegar.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/vinegar.vim b/plugin/vinegar.vim index 660ee29..871e23b 100644 --- a/plugin/vinegar.vim +++ b/plugin/vinegar.vim @@ -54,8 +54,9 @@ function! s:opendir(cmd) abort elseif expand('%') =~# '^$\|^term:[\/][\/]' execute a:cmd '.' else + let currentFilename = expand('%:t') execute a:cmd '%:h' . (expand('%:p') =~# '^\a\a\+:' ? s:slash() : '') - call s:seek(expand('#:t')) + call s:seek(currentFilename) endif endfunction