Hello,

On running gvim like this

    gvim --remote-tab-silent /some/path

Vim sends the following commands to server instance (this is just a
piece of bigger set of commands):

    cd /current/path
    tab drop /some/path
    if !exists('+acd') || !&acd
        cd -
    endif

`tab drop /some/path` triggers auto-commands, where one might want to
change directory for a new buffer.  *But* if 'autochdir' is not available
or disabled, `cd -` will overwrite that directory change.

I thought about adding a check to execute `cd -` only if we're still in
"/current/path" to implicitly detect directory changes made from
autocommands, like this

    if (!exists('+acd') || !&acd) && getcwd() ==# "/current/path"
        cd -
    endif

I made a sample patch, which seems to work, but there is probably a
better way to handle escaping and I didn't bother looking it up yet as I'm
not sure it's the best way to handle this issue.

So, is there a better way to fix this?  If not, please comment on the patch.
I'm particularly interested in ensuring that comparison with the path will
be syntactically correct, i.e. escaping will be done correctly for all
possible paths.

Best regards,
xaizek

-- 
-- 
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].
For more options, visit https://groups.google.com/d/optout.
diff -r eaf81729ef02 src/main.c
--- a/src/main.c        Tue Feb 10 20:03:46 2015 +0100
+++ b/src/main.c        Sat Feb 28 22:12:30 2015 +0200
@@ -3914,6 +3914,7 @@
     int                i;
     char_u     *inicmd = NULL;
     char_u     *p;
+    char_u     *cdp;
     char_u     *cwd;
 
     if (filec > 0 && filev[0][0] == '+')
@@ -3935,7 +3936,7 @@
        vim_free(cwd);
        return NULL;
     }
-    p = vim_strsave_escaped_ext(cwd,
+    cdp = vim_strsave_escaped_ext(cwd,
 #ifdef BACKSLASH_IN_FILENAME
                    "",  /* rem_backslash() will tell what chars to escape */
 #else
@@ -3943,12 +3944,11 @@
 #endif
                    '\\', TRUE);
     vim_free(cwd);
-    if (p == NULL)
+    if (cdp == NULL)
        return NULL;
     ga_init2(&ga, 1, 100);
     ga_concat(&ga, (char_u *)"<C-\\><C-N>:cd ");
-    ga_concat(&ga, p);
-    vim_free(p);
+    ga_concat(&ga, cdp);
 
     /* Call inputsave() so that a prompt for an encryption key works. */
     ga_concat(&ga, (char_u *)"<CR>:if exists('*inputsave')|call 
inputsave()|endif|");
@@ -3985,7 +3985,10 @@
     /* Switch back to the correct current directory (prior to temporary path
      * switch) unless 'autochdir' is set, in which case it will already be
      * correct after the :drop command. */
-    ga_concat(&ga, (char_u *)":if !exists('+acd')||!&acd|cd -|endif<CR>");
+    ga_concat(&ga, (char_u *)":if (!exists('+acd')||!&acd) && getcwd() ==# 
\"");
+    ga_concat(&ga, cdp);
+    ga_concat(&ga, (char_u *)"\"|cd -|endif<CR>");
+    vim_free(cdp);
 
     if (sendReply)
        ga_concat(&ga, (char_u *)":call SetupRemoteReplies()<CR>");

Attachment: pgp4srxClQokZ.pgp
Description: PGP signature

Raspunde prin e-mail lui