mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.3780: ":cd" works differently on MS-Windows
Problem: ":cd" works differently on MS-Windows.
Solution: Add the 'cdhome' option. (closes vim/vim#9324)
29f3a45915
This commit is contained in:
parent
0d7a97224f
commit
42cf76fd0a
@ -1253,10 +1253,12 @@ working directory. If a local working directory (tab or window) does not
|
|||||||
exist, the next-higher scope in the hierarchy applies.
|
exist, the next-higher scope in the hierarchy applies.
|
||||||
|
|
||||||
*:cd* *E747* *E472*
|
*:cd* *E747* *E472*
|
||||||
:cd[!] On non-Unix systems: Print the current directory
|
:cd[!] On non-Unix systems when 'cdhome' is off: Print the
|
||||||
name. On Unix systems: Change the current directory
|
current directory name.
|
||||||
to the home directory. Use |:pwd| to print the
|
Otherwise: Change the current directory to the home
|
||||||
current directory on all systems.
|
directory. Clear any window-local directory.
|
||||||
|
Use |:pwd| to print the current directory on all
|
||||||
|
systems.
|
||||||
|
|
||||||
:cd[!] {path} Change the current directory to {path}.
|
:cd[!] {path} Change the current directory to {path}.
|
||||||
If {path} is relative, it is searched for in the
|
If {path} is relative, it is searched for in the
|
||||||
|
@ -629,6 +629,7 @@ Short explanation of each option: *option-list*
|
|||||||
'buflisted' 'bl' whether the buffer shows up in the buffer list
|
'buflisted' 'bl' whether the buffer shows up in the buffer list
|
||||||
'buftype' 'bt' special type of buffer
|
'buftype' 'bt' special type of buffer
|
||||||
'casemap' 'cmp' specifies how case of letters is changed
|
'casemap' 'cmp' specifies how case of letters is changed
|
||||||
|
'cdhome' 'cdh' change directory to the home directory by ":cd"
|
||||||
'cdpath' 'cd' list of directories searched with ":cd"
|
'cdpath' 'cd' list of directories searched with ":cd"
|
||||||
'cedit' key used to open the command-line window
|
'cedit' key used to open the command-line window
|
||||||
'charconvert' 'ccv' expression for character encoding conversion
|
'charconvert' 'ccv' expression for character encoding conversion
|
||||||
|
@ -261,6 +261,10 @@ call <SID>OptionG("sect", §)
|
|||||||
call append("$", "path\tlist of directory names used for file searching")
|
call append("$", "path\tlist of directory names used for file searching")
|
||||||
call append("$", "\t(global or local to buffer)")
|
call append("$", "\t(global or local to buffer)")
|
||||||
call <SID>OptionG("pa", &pa)
|
call <SID>OptionG("pa", &pa)
|
||||||
|
if exists("+cdhome")
|
||||||
|
call <SID>AddOption("cdhome", "change directory to the home directory by :cd")
|
||||||
|
call <SID>BinOptionG("cdh", &cdh)
|
||||||
|
endif
|
||||||
call append("$", "cdpath\tlist of directory names used for :cd")
|
call append("$", "cdpath\tlist of directory names used for :cd")
|
||||||
call <SID>OptionG("cd", &cd)
|
call <SID>OptionG("cd", &cd)
|
||||||
if exists("+autochdir")
|
if exists("+autochdir")
|
||||||
|
@ -7807,14 +7807,17 @@ bool changedir_func(char_u *new_dir, CdScope scope)
|
|||||||
prev_dir = pdir;
|
prev_dir = pdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For UNIX ":cd" means: go to home directory.
|
||||||
|
// On other systems too if 'cdhome' is set.
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
// On Unix ":cd" means: go to home directory.
|
|
||||||
if (*new_dir == NUL) {
|
if (*new_dir == NUL) {
|
||||||
|
#else
|
||||||
|
if (*new_dir == NUL && p_cdh) {
|
||||||
|
#endif
|
||||||
// Use NameBuff for home directory name.
|
// Use NameBuff for home directory name.
|
||||||
expand_env((char_u *)"$HOME", NameBuff, MAXPATHL);
|
expand_env((char_u *)"$HOME", NameBuff, MAXPATHL);
|
||||||
new_dir = NameBuff;
|
new_dir = NameBuff;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
bool dir_differs = new_dir == NULL || pdir == NULL
|
bool dir_differs = new_dir == NULL || pdir == NULL
|
||||||
|| pathcmp((char *)pdir, (char *)new_dir, -1) != 0;
|
|| pathcmp((char *)pdir, (char *)new_dir, -1) != 0;
|
||||||
@ -7834,9 +7837,9 @@ void ex_cd(exarg_T *eap)
|
|||||||
{
|
{
|
||||||
char_u *new_dir;
|
char_u *new_dir;
|
||||||
new_dir = eap->arg;
|
new_dir = eap->arg;
|
||||||
#if !defined(UNIX) && !defined(VMS)
|
#if !defined(UNIX)
|
||||||
// for non-UNIX ":cd" means: print current directory
|
// for non-UNIX ":cd" means: print current directory unless 'cdhome' is set
|
||||||
if (*new_dir == NUL) {
|
if (*new_dir == NUL && !p_cdh) {
|
||||||
ex_pwd(NULL);
|
ex_pwd(NULL);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
@ -743,6 +743,7 @@ EXTERN int p_write; // 'write'
|
|||||||
EXTERN int p_wa; // 'writeany'
|
EXTERN int p_wa; // 'writeany'
|
||||||
EXTERN int p_wb; // 'writebackup'
|
EXTERN int p_wb; // 'writebackup'
|
||||||
EXTERN long p_wd; // 'writedelay'
|
EXTERN long p_wd; // 'writedelay'
|
||||||
|
EXTERN int p_cdh; // 'cdhome'
|
||||||
|
|
||||||
EXTERN int p_force_on; ///< options that cannot be turned off.
|
EXTERN int p_force_on; ///< options that cannot be turned off.
|
||||||
EXTERN int p_force_off; ///< options that cannot be turned on.
|
EXTERN int p_force_off; ///< options that cannot be turned on.
|
||||||
|
@ -274,6 +274,14 @@ return {
|
|||||||
varname='p_cmp',
|
varname='p_cmp',
|
||||||
defaults={if_true="internal,keepascii"}
|
defaults={if_true="internal,keepascii"}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
full_name='cdhome', abbreviation='cdh',
|
||||||
|
short_desc=N_("change directory to the home directory by :cd"),
|
||||||
|
type='bool', scope={'global'},
|
||||||
|
secure=true,
|
||||||
|
varname='p_cdh',
|
||||||
|
defaults={if_true=false}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
full_name='cdpath', abbreviation='cd',
|
full_name='cdpath', abbreviation='cd',
|
||||||
short_desc=N_("list of directories searched with \":cd\""),
|
short_desc=N_("list of directories searched with \":cd\""),
|
||||||
|
@ -64,6 +64,9 @@ if has('reltime')
|
|||||||
let s:start_time = reltime()
|
let s:start_time = reltime()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Always use forward slashes.
|
||||||
|
set shellslash
|
||||||
|
|
||||||
" Common with all tests on all systems.
|
" Common with all tests on all systems.
|
||||||
source setup.vim
|
source setup.vim
|
||||||
|
|
||||||
@ -104,9 +107,6 @@ lang mess C
|
|||||||
" Nvim: append runtime from build dir, which contains the generated doc/tags.
|
" Nvim: append runtime from build dir, which contains the generated doc/tags.
|
||||||
let &runtimepath .= ','.expand($BUILD_DIR).'/runtime/'
|
let &runtimepath .= ','.expand($BUILD_DIR).'/runtime/'
|
||||||
|
|
||||||
" Always use forward slashes.
|
|
||||||
set shellslash
|
|
||||||
|
|
||||||
let s:t_bold = &t_md
|
let s:t_bold = &t_md
|
||||||
let s:t_normal = &t_me
|
let s:t_normal = &t_me
|
||||||
if has('win32')
|
if has('win32')
|
||||||
|
@ -732,4 +732,25 @@ func Test_opt_reset_scroll()
|
|||||||
call delete('Xscroll')
|
call delete('Xscroll')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for the 'cdhome' option
|
||||||
|
func Test_opt_cdhome()
|
||||||
|
if has('unix') || has('vms')
|
||||||
|
throw 'Skipped: only works on non-Unix'
|
||||||
|
endif
|
||||||
|
|
||||||
|
set cdhome&
|
||||||
|
call assert_equal(0, &cdhome)
|
||||||
|
set cdhome
|
||||||
|
|
||||||
|
" This paragraph is copied from Test_cd_no_arg().
|
||||||
|
let path = getcwd()
|
||||||
|
cd
|
||||||
|
call assert_equal($HOME, getcwd())
|
||||||
|
call assert_notequal(path, getcwd())
|
||||||
|
exe 'cd ' .. fnameescape(path)
|
||||||
|
call assert_equal(path, getcwd())
|
||||||
|
|
||||||
|
set cdhome&
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Loading…
Reference in New Issue
Block a user