patch 9.1.1163: $MYVIMDIR is set too late
Commit:
https://github.com/vim/vim/commit/1a741d3cb8ff3bf1a7097a63bc70c537655d190d
Author: Christian Brabandt <[email protected]>
Date: Sat Mar 1 16:30:33 2025 +0100
patch 9.1.1163: $MYVIMDIR is set too late
Problem: $MYVIMDIR is set too late and not available while sourcing
runtime files (Maxim Kim, after v9.1.1159)
Solution: Also set it when $MYVIMRC file is found
fixes: #16764
closes: #16767
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/src/option.c b/src/option.c
index fa3454680..f61d72699 100644
--- a/src/option.c
+++ b/src/option.c
@@ -8420,6 +8420,8 @@ vimrc_found(char_u *fname, char_u *envname)
vim_setenv(envname, p);
vim_free(p);
}
+ // Set $MYVIMDIR
+ export_myvimdir();
}
else if (dofree)
vim_free(p);
diff --git a/src/optionstr.c b/src/optionstr.c
index 02806b66a..f4daabac5 100644
--- a/src/optionstr.c
+++ b/src/optionstr.c
@@ -135,7 +135,6 @@ static char *(p_sws_values[]) = {"fsync", "sync", NULL};
static int check_opt_strings(char_u *val, char **values, int list);
static int opt_strings_flags(char_u *val, char **values, unsigned *flagp, int
list);
-static void export_myvimdir(void);
/*
* After setting various option values: recompute variables that depend on
@@ -4817,7 +4816,7 @@ restore_shm_value(void)
/*
* Export the environment variable $MYVIMDIR to the first item in runtimepath
*/
- static void
+ void
export_myvimdir()
{
int dofree = FALSE;
diff --git a/src/proto/optionstr.pro b/src/proto/optionstr.pro
index 75a8d73b6..11b9d057c 100644
--- a/src/proto/optionstr.pro
+++ b/src/proto/optionstr.pro
@@ -198,4 +198,5 @@ char *did_set_string_option(int opt_idx, char_u **varp,
char_u *oldval, char_u *
int check_ff_value(char_u *p);
void save_clear_shm_value(void);
void restore_shm_value(void);
+void export_myvimdir(void);
/* vim: set ft=c : */
diff --git a/src/testdir/test_xdg.vim b/src/testdir/test_xdg.vim
index 15f82e2f6..b7abd04e6 100644
--- a/src/testdir/test_xdg.vim
+++ b/src/testdir/test_xdg.vim
@@ -21,7 +21,7 @@ func Test_xdg_rc_detection()
let rc = s:get_rcs()
let before =<< trim CODE
call writefile([expand('$MYVIMRC')], "XMY_VIMRC")
- call writefile([expand('$MYVIMRCDIR')], "XMY_VIMDIR")
+ call writefile([expand('$MYVIMDIR')], "XMY_VIMDIR")
quit!
CODE
call RunVim(before, [], "")
@@ -58,21 +58,30 @@ func Test_xdg_runtime_files()
" g:rc_one|two|three|four is to verify, that the other
" init files are not sourced
" g:rc is to verify which rc file has been loaded.
+ " g:rc_vimdir is to verify $MYVIMDIR is set and valid
let file1 =<< trim CODE
let g:rc_one = 'one'
let g:rc = '.vimrc'
+ let g:rc_vimdir = expand('~/.vim/')
+ call assert_equal(g:rc_vimdir, $MYVIMDIR)
CODE
let file2 =<< trim CODE
let g:rc_two = 'two'
let g:rc = '.vim/vimrc'
+ let g:rc_vimdir = expand('~/.vim/')
+ call assert_equal(g:rc_vimdir, $MYVIMDIR)
CODE
let file3 =<< trim CODE
let g:rc_three = 'three'
let g:rc = '.config/vim/vimrc'
+ let g:rc_vimdir = expand('~/.config/vim/')
+ call assert_equal(g:rc_vimdir, $MYVIMDIR)
CODE
let file4 =<< trim CODE
let g:rc_four = 'four'
let g:rc = 'xdg/vim/vimrc'
+ let g:rc_vimdir = expand('~/xdg/vim/')
+ call assert_equal(g:rc_vimdir, $MYVIMDIR)
CODE
call writefile(file1, rc1)
call writefile(file2, rc2)
@@ -87,7 +96,7 @@ func Test_xdg_runtime_files()
call assert_match('XfakeHOME/\.vimrc', $MYVIMRC)
call assert_match('XfakeHOME/.vim/', $MYVIMDIR)
call filter(g:, {idx, _ -> idx =~ '^rc'})
- call assert_equal(#{rc_one: 'one', rc: '.vimrc'}, g:)
+ call assert_equal(#{rc_one: 'one', rc: '.vimrc', rc_vimdir: $MYVIMDIR}, g:)
call assert_match('XfakeHOME/\.vim/view', &viewdir)
call writefile(v:errors, 'Xresult')
quit
@@ -103,7 +112,7 @@ func Test_xdg_runtime_files()
call assert_match('XfakeHOME/\.vim/vimrc', $MYVIMRC)
call assert_match('XfakeHOME/\.vim/', $MYVIMDIR)
call filter(g:, {idx, _ -> idx =~ '^rc'})
- call assert_equal(#{rc_two: 'two', rc: '.vim/vimrc'}, g:)
+ call assert_equal(#{rc_two: 'two', rc: '.vim/vimrc', rc_vimdir:
$MYVIMDIR}, g:)
call assert_match('XfakeHOME/\.vim/view', &viewdir)
call writefile(v:errors, 'Xresult')
quit
@@ -123,7 +132,7 @@ func Test_xdg_runtime_files()
call assert_match('XfakeHOME/\.config/vim/vimrc', $MYVIMRC, msg)
call assert_match('XfakeHOME/\.config/vim/', $MYVIMDIR, msg)
call filter(g:, {idx, _ -> idx =~ '^rc'})
- call assert_equal(#{rc_three: 'three', rc: '.config/vim/vimrc'}, g:)
+ call assert_equal(#{rc_three: 'three', rc: '.config/vim/vimrc', rc_vimdir:
$MYVIMDIR}, g:)
call assert_match('XfakeHOME/\.config/vim/view', &viewdir)
call writefile(v:errors, 'Xresult')
quit
@@ -141,7 +150,7 @@ func Test_xdg_runtime_files()
call assert_match('XfakeHOME/xdg/vim/vimrc', $MYVIMRC, msg)
call assert_match('XfakeHOME/xdg/vim/', $MYVIMDIR, msg)
call filter(g:, {idx, _ -> idx =~ '^rc'})
- call assert_equal(#{rc_four: 'four', rc: 'xdg/vim/vimrc'}, g:)
+ call assert_equal(#{rc_four: 'four', rc: 'xdg/vim/vimrc', rc_vimdir:
$MYVIMDIR}, g:)
call assert_match('XfakeHOME/xdg/vim/view, &viewdir)
call writefile(v:errors, 'Xresult')
quit
diff --git a/src/version.c b/src/version.c
index e95cf7e06..25c29256c 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1163,
/**/
1162,
/**/
--
--
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/E1toP1U-002dPn-3f%40256bit.org.