Open Oxore opened 1 year ago
The following change seems to be a fix for the issue, because the .lastd
file contains string cd '/path/to/file'
and not cd "/path/to/file"
:
diff --git a/autoload/nnn.vim b/autoload/nnn.vim
index 487d716..78592ae 100644
--- a/autoload/nnn.vim
+++ b/autoload/nnn.vim
@@ -235,7 +235,7 @@ function! s:create_on_exit_callback(opts)
let fname = s:nnn_conf_dir.'/.lastd'
if !empty(glob(fname))
let firstline = readfile(fname)[0]
- let lastd = split(firstline, '"')[1]
+ let lastd = split(firstline, "'")[1]
execute 'cd' fnameescape(lastd)
call delete(fnameescape(fname))
endif
But I'm not sure that it does not break anything else. Going to investigate further and test it more, but later.
Since https://github.com/jarun/nnn/commit/57882ffab713e66690d29714a7fbea2cb2e61a5f nnn
already shell escapes the filename. So I suspect that fnameescape
call might not be correct anymore as well.
That commit may be the reason why this issue arose at all. @N-R-K thank you for sharing. A fix for this issue should probably be inclusive for both single quote and double quote cases, because not everyone is using the newest nnn
version.
Also splitting string by quotation marks may not work for paths that contain '
and "
anyway.
Describe the bug
I get multiple Neovim errors when I exit nnn picker without choosing a file, i.e. by pressing
q
.To Reproduce
Minimal configuration:
Steps to reproduce:
nvim -u testrc.vim testrc.vim
.:NnnPicker %:p:h
. This is recommended way in the readme to make nnn start in the current file's directory.q
on the opened nnn picker window.After this the behavior is proper: Neovim shows previously opened file, no problem. Error messages are the problem basically.
The text of the error:
Expected behavior
Close nnn picker window by
q
key hit without errors and show previously opened file.Screenshots
Environment:
e0104e369508fc12e3651ad4dee20261b5b3e87f
Additional context
The
%:p:h
argument is actually not relevant. Starting:NnnPicker
without arguments will lead to errors too when NNN closed byq
. I found it after I already took screenshots and decided to leave "steps to reproduce" section as is.