From 3e60af2c183715cfeac6087a0d1c5f8fc01f280b Mon Sep 17 00:00:00 2001 From: Brian Clements-Tiberio Date: Tue, 17 Feb 2026 13:27:17 -0800 Subject: [PATCH] fix(autoload/nnn.vim): Guard irregular return format in lastd Quitting with "q" using NnnPicker returns errors to the user. This makes the value of lastd regular in that case so it's safe to quit/abort a NnnPicker window having not selected anything. --- autoload/nnn.vim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/autoload/nnn.vim b/autoload/nnn.vim index 487d716..76d652c 100644 --- a/autoload/nnn.vim +++ b/autoload/nnn.vim @@ -235,8 +235,11 @@ 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] - execute 'cd' fnameescape(lastd) + let parts = split(firstline, '"') + if len(parts) > 1 + let lastd = parts[1] + execute 'cd' fnameescape(lastd) + endif call delete(fnameescape(fname)) endif endfunction