Commit: patch 9.2.0980: runtime(netrw): prioritize g:netrw_home on Neovim

Christian Brabandt <[email protected]>
Newsgroups gmane.editors.vim.devel
Message-ID <[email protected]>
patch 9.2.0980: runtime(netrw): prioritize g:netrw_home on Neovim

Commit: https://github.com/vim/vim/commit/4be03620b305282270e41643e5e860f95efa8f07
Author: J. Paulo Seibt <[email protected]>
Date:   Wed Aug 19 19:41:34 2026 +0000

    patch 9.2.0980: runtime(netrw): prioritize g:netrw_home on Neovim
    
    Problem:  runtime(netrw): g:netrw_home not respected on Neovim
    Solution: prioritize g:netrw_home for bookmarks and history directory
              setting, add tests (J. Paulo Seibt)
    
    related: neovim/neovim@5a78c5b
    closes:  #21091
    
    Signed-off-by: J. Paulo Seibt <[email protected]>
    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 d745fd36f..0347ec497 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 <[email protected]>
 " Maintainer: This runtime file is looking for a new maintainer.
-" Last Change: 2026 Jul 23
+" Last Change: 2026 Aug 19
 " 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
@@ -4459,10 +4459,10 @@ endfunction
 
 "  s:NetrwHome: this function determines a "home" for saving bookmarks and history {{{2
 function s:NetrwHome()
-    if has('nvim')
-        let home = netrw#fs#PathJoin(stdpath('state'), 'netrw')
-    elseif exists('g:netrw_home')
+    if exists('g:netrw_home')
         let home = expand(g:netrw_home)
+    elseif has('nvim')
+        let home = netrw#fs#PathJoin(stdpath('state'), 'netrw')
     elseif exists('$MYVIMDIR')
         let home = expand('$MYVIMDIR')->substitute('/$', '', '')
     else
diff --git a/src/testdir/test_plugin_netrw.vim b/src/testdir/test_plugin_netrw.vim
index 2530b0a70..e6ce769ce 100644
--- a/src/testdir/test_plugin_netrw.vim
+++ b/src/testdir/test_plugin_netrw.vim
@@ -196,6 +196,11 @@ function Test_NetrwMarkFile_match_pattern_rebuild()
 
   bw
 endfunction
+
+" Test the "home" directory used for bookmarks and history
+function Test_NetrwHome() abort
+    return s:NetrwHome()
+endfunction
 " }}}
 END
 
@@ -912,4 +917,39 @@ func Test_netrw_open_no_dir_arg()
   bw!
 endfunc
 
+func Test_netrw_home_setting()
+  let save_home = get(g:, 'netrw_home', '')
+  let dir = fnamemodify('XnetrwHome', ':p:h')
+  if has('win32')
+    let dir = substitute(dir, '/', '\', 'g')
+  endif
+ 
+  if has('nvim')
+    unlet! g:netrw_home
+    call assert_equal(netrw#fs#PathJoin(stdpath('state'), 'netrw'), Test_NetrwHome())
+  endif
+
+  let g:netrw_home = dir
+  call assert_equal(dir, Test_NetrwHome())
+  call assert_true(isdirectory(dir))
+
+  " the value is expanded
+  let $NETRW_TEST_HOME = dir
+  let g:netrw_home = '$NETRW_TEST_HOME'
+  call assert_equal(dir, Test_NetrwHome())
+
+  " without the setting $MYVIMDIR is used
+  unlet g:netrw_home
+  let $MYVIMDIR = dir
+  call assert_equal(dir, Test_NetrwHome())
+
+  call delete(dir, 'd')
+  let $NETRW_TEST_HOME = ''
+  if empty(save_home)
+    unlet! g:netrw_home
+  else
+    let g:netrw_home = save_home
+  endif
+endfunc
+
 " vim:ts=8 sts=2 sw=2 et
diff --git a/src/version.c b/src/version.c
index 257d31223..e5ab4cc8a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -763,6 +763,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    980,
 /**/
     979,
 /**/

-- 
-- 
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/E1wwmgh-00CODf-Pz%40256bit.org.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.