mirror of
https://github.com/neovim/neovim.git
synced 2025-09-17 08:48:16 +00:00
vim-patch:5346688: 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: vim/vim#9862
closes: vim/vim#18069
53466887f7
Co-authored-by: Jason Long <jasonlongball@gmail.com>
This commit is contained in:
10
runtime/pack/dist/opt/netrw/autoload/netrw.vim
vendored
10
runtime/pack/dist/opt/netrw/autoload/netrw.vim
vendored
@@ -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"),'^\(.*[/\\]\)[^/\\]*$','\1','e')
|
||||
if !exists("g:netrw_cygwin") && has("win32")
|
||||
let curdir= substitute(curdir,'\','/','g')
|
||||
endif
|
||||
let curfiledir = substitute(expand("%:p"),'^\(.*[/\\]\)[^/\\]*$','\1','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
|
||||
|
Reference in New Issue
Block a user