]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0235: 'autoshelldir' does not work with chunked respose v9.0.0235
authorBram Moolenaar <Bram@vim.org>
Sun, 21 Aug 2022 10:37:17 +0000 (11:37 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 21 Aug 2022 10:37:17 +0000 (11:37 +0100)
Problem:    'autoshelldir' does not work with chunked respose.
Solution:   Collect chunks before parsing OSC 7. (closes #10949)

src/terminal.c
src/version.c

index a951870057257f4ebe6b017d43646e82fc9a6b40..c0fa1254ebc461279077fb6d0902e42bd9327829 100644 (file)
@@ -4477,28 +4477,28 @@ url_decode(const char *src, const size_t len, char_u *dst)
  * "file://HOSTNAME/CURRENT/DIR"
  */
     static void
-sync_shell_dir(VTermStringFragment *frag)
+sync_shell_dir(garray_T *gap)
 {
-    int       offset = 7; // len of "file://" is 7
-    char      *pos = (char *)frag->str + offset;
+    int       offset = 7;  // len of "file://" is 7
+    char      *pos = (char *)gap->ga_data + offset;
     char_u    *new_dir;
 
     // remove HOSTNAME to get PWD
-    while (*pos != '/' && offset < (int)frag->len)
+    while (offset < (int)gap->ga_len && *pos != '/' )
     {
-       offset += 1;
-       pos += 1;
+       ++offset;
+       ++pos;
     }
 
-    if (offset >= (int)frag->len)
+    if (offset >= (int)gap->ga_len)
     {
        semsg(_(e_failed_to_extract_pwd_from_str_check_your_shell_config),
-                                                                   frag->str);
+                                                                gap->ga_data);
        return;
     }
 
-    new_dir = alloc(frag->len - offset + 1);
-    url_decode(pos, frag->len-offset, new_dir);
+    new_dir = alloc(gap->ga_len - offset + 1);
+    url_decode(pos, gap->ga_len-offset, new_dir);
     changedir_func(new_dir, TRUE, CDSCOPE_WINDOW);
     vim_free(new_dir);
 }
@@ -4518,13 +4518,7 @@ parse_osc(int command, VTermStringFragment frag, void *user)
     garray_T   *gap = &term->tl_osc_buf;
 
     // We recognize only OSC 5 1 ; {command} and OSC 7 ; {command}
-    if (p_asd && command == 7)
-    {
-       sync_shell_dir(&frag);
-       return 1;
-    }
-
-    if (command != 51)
+    if (command != 51 && (command != 7 || !p_asd))
        return 0;
 
     // Concatenate what was received until the final piece is found.
@@ -4539,6 +4533,14 @@ parse_osc(int command, VTermStringFragment frag, void *user)
        return 1;
 
     ((char *)gap->ga_data)[gap->ga_len] = 0;
+
+    if (command == 7)
+    {
+       sync_shell_dir(gap);
+       ga_clear(gap);
+       return 1;
+    }
+
     reader.js_buf = gap->ga_data;
     reader.js_fill = NULL;
     reader.js_used = 0;
index 07b571d8fa8c77884118970966b3453aeaa23a86..616f748c40c2a96531f354e7e9417dafb927a837 100644 (file)
@@ -731,6 +731,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    235,
 /**/
     234,
 /**/