-
-
Notifications
You must be signed in to change notification settings - Fork 88
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
Using - in modified buffer produces error when nohidden #77
Comments
This does make sense: without Note, |
It makes sense, it's just an ugly multi-line error and it's not entirely clear what the reason is. I'm going to close this because I don't think it necessarily needs any attention. |
I see your point. Following patch would remove the multi-line error: diff --git a/plugin/vinegar.vim b/plugin/vinegar.vim
index 85ed2a4..a50b4ba 100644
--- a/plugin/vinegar.vim
+++ b/plugin/vinegar.vim
@@ -43,16 +43,20 @@ function! s:opendir(cmd) abort
if expand('%:t')[0] ==# '.' && g:netrw_list_hide[-strlen(df):-1] ==# df
let g:netrw_list_hide = g:netrw_list_hide[0 : -strlen(df)-1]
endif
- if &filetype ==# 'netrw'
- let currdir = fnamemodify(b:netrw_curdir, ':t')
- execute s:netrw_up
- call s:seek(currdir)
- elseif expand('%') =~# '^$\|^term:[\/][\/]'
- execute a:cmd '.'
- else
- execute a:cmd '%:h/'
- call s:seek(expand('#:t'))
- endif
+ try
+ if &filetype ==# 'netrw'
+ let currdir = fnamemodify(b:netrw_curdir, ':t')
+ execute s:netrw_up
+ call s:seek(currdir)
+ elseif expand('%') =~# '^$\|^term:[\/][\/]'
+ execute a:cmd '.'
+ else
+ execute a:cmd '%:h/'
+ call s:seek(expand('#:t'))
+ endif
+ catch /.*/
+ echo v:exception
+ endtry
endfunction
function! s:seek(file) abort This returns a one-liner:
Another option is following diff which avoids orphan/stray netrw buffers which occur when ❯ git diff
diff --git a/plugin/vinegar.vim b/plugin/vinegar.vim
index 28adce4..a59e279 100644
--- a/plugin/vinegar.vim
+++ b/plugin/vinegar.vim
@@ -29,7 +29,7 @@ if !exists("g:netrw_special_syntax")
endif
let s:netrw_up = ''
-nnoremap <silent> <Plug>VinegarUp :call <SID>opendir('edit')<CR>
+nnoremap <silent> <Plug>VinegarUp :call <SID>opendir('Explore')<CR>
if empty(maparg('-', 'n'))
nmap - <Plug>VinegarUp
endif In this case no error is raised the netrw buffer is forced to be open in a split window without explicitly using
|
If the current file is modified and unsaved, and
nohidden
is set, and I hit-
, I get this error:I would never normally use vim with
nohidden
, and I have no idea how it even got set that way, so this isn't really a big deal. I sethidden
and it worked fine. I restarted vim just to check and see if for some reason vinegar had changed the flag, and of course hadhidden
set, so everything's fine...but you might want to check for this and handle the scenario more cleanly.The text was updated successfully, but these errors were encountered: