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>
diff --git a/src/clientserver.c b/src/clientserver.c
index 340add3..b19cd44 100644
--- a/src/clientserver.c
+++ b/src/clientserver.c
@@ -608,7 +608,7 @@
 
     // 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 @@
     //    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);