Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- broken under Vim >= 9.0 ? #136

Open
Konfekt opened this issue Mar 13, 2024 · 2 comments
Open

- broken under Vim >= 9.0 ? #136

Konfekt opened this issue Mar 13, 2024 · 2 comments

Comments

@Konfekt
Copy link
Contributor

Konfekt commented Mar 13, 2024

Using Vim 9.0.2103 under Linux with netrwPlugin.vim from Feb 09, 2021.

Typing

vim --clean -u ~/.viminrc

with ~/.viminrc reading

set nocompatible
let &rtp = '~/.vim/plugged/vim-vinegar/' . ',' . &rtp

then

:~/.vim/plugged/vim-vinegar/README.markdown<cr>-

shows the cursor at the first line instead of README.markdown.

@Konfekt
Copy link
Contributor Author

Konfekt commented Mar 13, 2024

The issue persists under Vim 9.1.151 and (autoload) netrw (from 2024 Feb 29)

@Konfekt
Copy link
Contributor Author

Konfekt commented Mar 13, 2024

The only workaround I could come up with is temporarily switching to the file's dir, such as adding

nnoremap <silent> <SID>(lcd) :<c-u>lcd %:p:h<CR>
nmap <silent> - <SID>(lcd)<Plug>VinegarUp

or, to restore the current work dir,

  nnoremap <silent> - :<c-u>call <SID>VinegarUp()<CR>
  fun s:VinegarUp()
		let save_dir = chdir(expand('%:p:h'))
		if !empty(save_dir)
          exe "normal \<Plug>VinegarUp"
		  call chdir(save_dir)
		endif
  endf

to ~/.viminrc

serebrov added a commit to serebrov/vim-vinegar that referenced this issue Jun 28, 2024
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 tpope#136
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant