Coder Social home page Coder Social logo

Comments (4)

chrisbra avatar chrisbra commented on May 27, 2024

That whole build_drop_cmd() function is a big mess wich dynamically concates some VimScript functionality to perform the actual work. It could benefit from re-doing the whole thing perhaps in VimScript, so it is easier to make adjustments.

Anyhow, I think the following patch should fix the problem:

diff --git a/src/clientserver.c b/src/clientserver.c
index 340add315..f1987743b 100644
--- a/src/clientserver.c
+++ b/src/clientserver.c
@@ -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
+    // undo the effect of 'shellslash', / shouldn't be allowed to be in any valid
+    // path on Windows, 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);

from vim.

Jajauma avatar Jajauma commented on May 27, 2024

Yes, this fixes the problem. In the patch you need to escape the backslash ("... tr('/','\\') ..."), but still.

On the other hand, it may be more explicit and easier to comprehend to temporarily reset the 'shellslash' setting (if it exists) for the duration of the operation, as is already done with 'wildignore'.

from vim.

chrisbra avatar chrisbra commented on May 27, 2024

On the other hand, it may be more explicit and easier to comprehend to temporarily reset the 'shellslash' setting (if it exists) for the duration of the operation, as is already done with 'wildignore'.

Yeah, but it is already quite complicated and one would need to test that 'shellslash' exists. I think tr() is easier.

Yes, this fixes the problem. In the patch you need to escape the backslash ("... tr('/','\') ..."), but still.

No, I don't think so. It errors out otherwise: :set shellslash|:cd c:\temp|echo getcwd()->tr('/','\\'): E475: invalid argument: /

from vim.

Jajauma avatar Jajauma commented on May 27, 2024

To my understaing the Vim snippet tr('/','\') is fine, it is the C string literal that requires escaping:

    ga_concat(&ga, (char_u *)"cd -|lcd -|elseif getcwd()->tr('/','\\') ==# '");

so you can actually get

cd -|lcd -|elseif getcwd()->tr('/','\') ==# '

sent to the server.

from vim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.