tpope / vim-vinegar

vinegar.vim: Combine with netrw to create a delicious salad dressing
https://www.vim.org/scripts/script.php?script_id=5671
2.23k stars 87 forks source link

No correct output for `expand('%')` #127

Closed hanleylee closed 3 years ago

hanleylee commented 3 years ago

I encounter a strange issue: when I use - go into netrw, I can't get correct output by :echo expand('%').

If I just use :Explore go into netrw, the output for :echo expand('%') is correct. I already test this by unload all plugin except vim-vinegar. I can confirm it's a bug because of vim-vinegar. Following is my configuration:

let g:netrw_hide = 0 "设置默认隐藏
let g:netrw_liststyle = 0 " tree 模式显示风格
let g:netrw_banner = 0 " 显示帮助信息
let g:netrw_browse_split = 0 "控制 <CR> 直接在当前窗口打开光标下文件
let g:netrw_winsize = 30 " 占用宽度
let g:netrw_list_hide= '\(^\|\s\s\)\zs\.\S\+' " 需要隐藏的文件
let g:netrw_altv = 1 " 控制 v 分裂的窗口位于右边
let g:netrw_preview = 1 " 默认是水平分割, 此项设置使之垂直分割
let g:netrw_alto = 0 " 控制预览窗口位于左侧或右侧, 与 netrw_preview 共同作用
let g:netrw_keepdir=0
let g:netrw_special_syntax=1
let g:netrw_localcopydircmd = 'cp -r'
let g:netrw_nogx = 1 " disable gx keymap
tpope commented 3 years ago

I can't reproduce, even with those exact options. What Vim version? What netrw version?

hanleylee commented 3 years ago

Thanks for your patience! After I try many times(in vanilla on MacOS and Linux), I found the reason is set hidden.

I can't get any output by :echo expand('%') for the first time - into netrw after I add this line to my vimrc, everything will be ok after I remove this line.

Please check it again.

hanleylee commented 3 years ago

I found you make a new commit for this issue, so I update vim-vinegar to latest.

Actually, this issue still exists, can you try it again?

tpope commented 3 years ago

I can no longer reproduce the problem. What happens if you do :e %:h to enter netrw?

hanleylee commented 3 years ago

If I have file ~/.vim/vimrc, then I use vim ~/.vim/vimrc to edit this file, I will get the following result by different action

config action echo result
set nohidden :Explore :echo expand('%') ~/.vim
set nohidden :e %:h :echo expand('%') ~/.vim
set nohidden - :echo expand('%') ~/.vim
set hidden :Explore :echo expand('%') ~/.vim
set hidden :e %:h :echo expand('%') NONE
set hidden - | :echo expand('%') NONE

I reproduced this by creating a docker image, you can check it https://hub.docker.com/r/hanleylee/test_vinegar

tpope commented 3 years ago

Please provide step by step instructions for using this Docker image. Pretend you're talking to someone who rarely uses Docker.