From 6003545f3818ca62865b2f66904ed8b068f84a1b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 2 Jul 2026 07:45:14 +0800 Subject: [PATCH] vim-patch:9.2.0761: runtime(netrw): Unix: unable to open '\' file (#40533) Problem: runtime(netrw): Unix: unable to open '\' file Solution: Adjust directory pattern (Manoj Panda) closes: vim/vim#20685 https://github.com/vim/vim/commit/86d8af37ba90ced2236afcb3572c6cb2a1594788 Co-authored-by: Manoj Panda --- .../pack/dist/opt/netrw/autoload/netrw.vim | 4 ++-- test/old/testdir/test_plugin_netrw.vim | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/runtime/pack/dist/opt/netrw/autoload/netrw.vim b/runtime/pack/dist/opt/netrw/autoload/netrw.vim index 69f145cec3..67dbdccc5f 100644 --- a/runtime/pack/dist/opt/netrw/autoload/netrw.vim +++ b/runtime/pack/dist/opt/netrw/autoload/netrw.vim @@ -1,7 +1,7 @@ " Creator: Charles E Campbell " Previous Maintainer: Luca Saccarola " Maintainer: This runtime file is looking for a new maintainer. -" Last Change: 2026 Jun 28 +" Last Change: 2026 Jul 01 " 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 @@ -3862,7 +3862,7 @@ function s:NetrwBrowseChgDir(islocal, newdir, cursor, ...) endif " set up o/s-dependent directory recognition pattern - let dirpat = has("amiga") ? '[\/:]$' : '[\/]$' + let dirpat = has("amiga") || has('win32') ? '[\/:]$' : '/$' if newdir !~ dirpat && !(a:islocal && isdirectory(s:NetrwFile(netrw#fs#ComposePath(dirname, newdir)))) " ------------------------------ diff --git a/test/old/testdir/test_plugin_netrw.vim b/test/old/testdir/test_plugin_netrw.vim index 0e9f43165a..d1132ca906 100644 --- a/test/old/testdir/test_plugin_netrw.vim +++ b/test/old/testdir/test_plugin_netrw.vim @@ -885,4 +885,27 @@ func Test_netrw_forward_slashes() bw! endfunc +" Selecting a file whose name is a single backslash +func Test_netrw_open_backslash_file() + CheckUnix + + let dir = getcwd() . '/Xbslash' + let fname = dir . '/\' + call mkdir(dir, 'p') + call writefile(['backslash file content'], fname) + call assert_true(filereadable(fname)) + + " list the directory and move onto the '\' entry + exe 'Explore ' .. dir + call assert_true(search('^\\$', 'w') > 0) + + " open it + exe "normal \" + + call assert_equal('\', expand('%:t')) + call assert_equal(['backslash file content'], getline(1, '$')) + + bw! +endfunc + " vim:ts=8 sts=2 sw=2 et