0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

patch 9.1.0356: MS-Windows: --remote may change working directory

Problem:  MS-Windows: --remote may change working directory when
          'shellslash' is set
Solution: normalize directory separators on MS-Windows

fixes: #14549
closes: #14587

Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Christian Brabandt
2024-04-19 15:22:33 +02:00
parent cee034112d
commit 349f5cd818
3 changed files with 54 additions and 1 deletions

View File

@@ -608,7 +608,7 @@ build_drop_cmd(
// Call inputsave() so that a prompt for an encryption key works.
ga_concat(&ga, (char_u *)
"<CR>:if exists('*inputsave')|call inputsave()|endif|");
"<CR><C-\\><C-N>:if exists('*inputsave')|call inputsave()|endif|");
if (tabs)
ga_concat(&ga, (char_u *)"tab ");
ga_concat(&ga, (char_u *)"drop");
@@ -652,7 +652,13 @@ build_drop_cmd(
// endif
// endif
ga_concat(&ga, (char_u *)":if !exists('+acd')||!&acd|if haslocaldir()|");
#ifdef MSWIN
// in case :set shellslash is set, need to normalize the directory separators
// '/' is not valid in a filename so replacing '/' by '\\' should be safe
ga_concat(&ga, (char_u *)"cd -|lcd -|elseif getcwd()->tr('/','\\') ==# '");
#else
ga_concat(&ga, (char_u *)"cd -|lcd -|elseif getcwd() ==# '");
#endif
ga_concat(&ga, cdp);
ga_concat(&ga, (char_u *)"'|cd -|endif|endif<CR>");
vim_free(cdp);