[vim/vim] runtime(netrw): Going up in the browsing windows doesn't work over ssh (PR #18199)

10 views
Skip to first unread message

MiguelBarro

unread,
Sep 3, 2025, 1:08:15 PMSep 3
to vim/vim, Subscribed

Over ssh the netrw browsing window cannot go up (tries to open a non-existing file).
The s:NetrwBrowse() function requires a:
https://github.com/vim/vim/blob/f165798184dc03895709704df864bd1e43eaf09f/runtime/pack/dist/opt/netrw/autoload/netrw.vim#L3034
for remote files that is missing in this case.
The pull request merely restores the old behaviour as fix:
https://github.com/vim/vim/blob/223189389a18acf6e074ab0ca1a3bb6a4ec27ef7/runtime/pack/dist/opt/netrw/autoload/netrw.vim#L3882


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/18199

Commit Summary

  • bfc81cf runtime(netrw): fix s:NetrwBrowseChgDir() recovering the old v9.1.1484 behaviour.

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18199@github.com>

MiguelBarro

unread,
Sep 4, 2025, 5:07:35 AMSep 4
to vim/vim, Push

@MiguelBarro pushed 1 commit.

  • 4797d60 runtime(netrw): restrict the fix to the 'go up' use case only


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18199/before/bfc81cf357b470bfab89e61cddd6d365e4a3a7cc/after/4797d60dfbb98f3ba38529ee979ad9b4ca4744cc@github.com>

Christian Brabandt

unread,
Sep 4, 2025, 3:54:11 PMSep 4
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In runtime/pack/dist/opt/netrw/autoload/netrw/fs.vim:

> @@ -87,7 +87,8 @@ endfunction
 " netrw#fs#Dirname: {{{
 
 function netrw#fs#Dirname(path)
-    return netrw#fs#AbsPath(a:path)->fnamemodify(':h')
+    " Keep a slash as directory recognition pattern
+    return (a:path !~ s:slash . '$') ? a:path . s:slash : a:path

But this means we are no longer making it a full path. Should we perhaps do it like this instead?

let path = netrw#fs#AbsPath(a:path)->fnamemodify(':h')
return (path !~ s:slash . '$') ? path . s:slash : a:path


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18199/review/3186973347@github.com>

MiguelBarro

unread,
Sep 4, 2025, 7:48:04 PMSep 4
to vim/vim, Subscribed

@MiguelBarro commented on this pull request.


In runtime/pack/dist/opt/netrw/autoload/netrw/fs.vim:

> @@ -87,7 +87,8 @@ endfunction
 " netrw#fs#Dirname: {{{
 
 function netrw#fs#Dirname(path)
-    return netrw#fs#AbsPath(a:path)->fnamemodify(':h')
+    " Keep a slash as directory recognition pattern
+    return (a:path !~ s:slash . '$') ? a:path . s:slash : a:path

That's a good point. But netrw#fs#AbsPath(a:path) will always remove the slash, we no longer need the check:

    function netrw#fs#Dirname(path)
        " Keep a slash as directory recognition pattern
        return netrw#fs#AbsPath(a:path) . s:slash
    endfunction

will do.
Note fnamemodify(':h') must be removed because without a slash at the end it will remove the current dir. For example:

:echo "scp://ds//opt/nvidia/deepstream"->fnamemodify(':h')
    scp://ds//opt/nvidia
:echo "scp://ds//opt/nvidia/deepstream/"->fnamemodify(':h')
    scp://ds//opt/nvidia/deepstream

Later the execution of:
https://github.com/vim/vim/blob/9fd1a657d2efae5cff278eb5acaa380623a50cf6/runtime/pack/dist/opt/netrw/autoload/netrw.vim#L3977-L3985
will go up another dir again...a double jump.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18199/review/3187556181@github.com>

MiguelBarro

unread,
Sep 4, 2025, 7:48:20 PMSep 4
to vim/vim, Push

@MiguelBarro pushed 1 commit.

  • 651b232 runtime(netrw): addressing reviewer's comments. Assure netrw#fs#Dirname() returns resolved paths.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18199/before/4797d60dfbb98f3ba38529ee979ad9b4ca4744cc/after/651b2321a77ded9d5fed6ec1cce789fc0d3faa32@github.com>

Christian Brabandt

unread,
Sep 5, 2025, 5:29:56 AMSep 5
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18199)

okay thanks.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18199/c3257698361@github.com>

Christian Brabandt

unread,
Sep 5, 2025, 5:34:37 AMSep 5
to vim/vim, Subscribed

Closed #18199 via 5f83674.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18199/issue_event/19525420603@github.com>

MiguelBarro

unread,
4:45 AM (11 hours ago) 4:45 AM
to vim/vim, Subscribed
MiguelBarro left a comment (vim/vim#18199)

Reviewing #18421 I realized this PR only works properly on windows if 'shellslash' is on (not the default).

The main issue is there are several places in the sources where the directory goes up:

As was revamp:

  • Local filesystem goes updir in A and B is ignored (no / ending).
  • SSH paths: neither A nor B goes updir (the original PR issue):
    • A just remove the terminal /
    • B doesn't work without terminal /.

After this PR B never goes updir and A does the job again ... at least if 'shellslash' is on.
If 'shellslash' is off (default) then A fails because dirname ends in `' instead.

The fix is not as easy as using / in netrw#fs#Dirname() because the A regex expect all separators to be /.
The easiest workaround is normalizing all path separators to / before using the regexp or modify the regexp to cope with any separator.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18199/c3350731608@github.com>

Reply all
Reply to author
Forward
0 new messages