runtime(netrw): fix :Explore command in terminal
Commit:
https://github.com/vim/vim/commit/53466887f71f47ae74227a69ba15120e5f9a161b
Author: Jason Long <[email protected]>
Date: Sat Aug 23 17:44:32 2025 +0200
runtime(netrw): fix :Explore command in terminal
There are really two issues solved here:
- The directory listing was not populating the new buffer when using
the :Explore command. This was because the directory to open is
determined by using expand("%:p") which includes '!/running/command' at
the end of the string in terminal buffers.
- The :Explore command should replace the buffer, not split it. This
because the Explore command will automatically split if the current
buffer has been modified. According to the docs, all terminal buffers
will have the modified flag set when a job is running.
fixes: #9862
closes: #18069
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/runtime/pack/dist/opt/netrw/autoload/netrw.vim
b/runtime/pack/dist/opt/netrw/autoload/netrw.vim
index 15a45b37c..1c98104d0 100644
--- a/runtime/pack/dist/opt/netrw/autoload/netrw.vim
+++ b/runtime/pack/dist/opt/netrw/autoload/netrw.vim
@@ -4,6 +4,7 @@
" Last Change:
" 2025 Aug 07 by Vim Project (use correct "=~#" for netrw_stylesize option
#17901)
" 2025 Aug 07 by Vim Project (netrw#BrowseX() distinguishes remote files
#17794)
+" 2025 Aug 22 by Vim Project netrw#Explore handle terminal correctly #18069
" Copyright: Copyright (C) 2016 Charles E. Campbell {{{1
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
@@ -430,10 +431,13 @@ function netrw#Explore(indx,dosplit,style,...)
" record current directory
let curdir = simplify(b:netrw_curdir)
- let curfiledir = substitute(expand("%:p"),'^\(.*[/\]\)[^/\]*$',' ','e')
if !exists("g:netrw_cygwin") && has("win32")
let curdir= substitute(curdir,'\','/','g')
endif
+ let curfiledir = substitute(expand("%:p"),'^\(.*[/\]\)[^/\]*$',' ','e')
+ if &buftype == "terminal"
+ let curfiledir = curdir
+ endif
" using completion, directories with spaces in their names (thanks, Bill
Gates, for a truly dumb idea)
" will end up with backslashes here. Solution: strip off backslashes that
precede white space and
@@ -456,9 +460,9 @@ function netrw#Explore(indx,dosplit,style,...)
sil! let keepregslash= @/
" if dosplit
- " -or- file has been modified AND file not hidden when abandoned
+ " -or- buffer is not a terminal AND file has been modified AND file not
hidden when abandoned
" -or- Texplore used
- if a:dosplit || (&modified && &hidden == 0 && &bufhidden != "hide") ||
a:style == 6
+ if a:dosplit || (&buftype != "terminal" && &modified && &hidden == 0 &&
&bufhidden != "hide") || a:style == 6
call s:SaveWinVars()
let winsz= g:netrw_winsize
if a:indx > 0
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1upqez-00F9AX-4p%40256bit.org.