Patch 9.0.0235
Problem:    'autoshelldir' does not work with chunked respose.
Solution:   Collect chunks before parsing OSC 7. (closes #10949)
Files:      src/terminal.c


*** ../vim-9.0.0234/src/terminal.c      2022-08-14 14:16:08.003582142 +0100
--- src/terminal.c      2022-08-21 11:35:39.348777437 +0100
***************
*** 4477,4504 ****
   * "file://HOSTNAME/CURRENT/DIR"
   */
      static void
! sync_shell_dir(VTermStringFragment *frag)
  {
!     int       offset = 7; // len of "file://" is 7
!     char      *pos = (char *)frag->str + offset;
      char_u    *new_dir;
  
      // remove HOSTNAME to get PWD
!     while (*pos != '/' && offset < (int)frag->len)
      {
!       offset += 1;
!       pos += 1;
      }
  
!     if (offset >= (int)frag->len)
      {
        semsg(_(e_failed_to_extract_pwd_from_str_check_your_shell_config),
!                                                                   frag->str);
        return;
      }
  
!     new_dir = alloc(frag->len - offset + 1);
!     url_decode(pos, frag->len-offset, new_dir);
      changedir_func(new_dir, TRUE, CDSCOPE_WINDOW);
      vim_free(new_dir);
  }
--- 4477,4504 ----
   * "file://HOSTNAME/CURRENT/DIR"
   */
      static void
! sync_shell_dir(garray_T *gap)
  {
!     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 (offset < (int)gap->ga_len && *pos != '/' )
      {
!       ++offset;
!       ++pos;
      }
  
!     if (offset >= (int)gap->ga_len)
      {
        semsg(_(e_failed_to_extract_pwd_from_str_check_your_shell_config),
!                                                                gap->ga_data);
        return;
      }
  
!     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,4530 ****
      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)
        return 0;
  
      // Concatenate what was received until the final piece is found.
--- 4518,4524 ----
      garray_T  *gap = &term->tl_osc_buf;
  
      // We recognize only OSC 5 1 ; {command} and OSC 7 ; {command}
!     if (command != 51 && (command != 7 || !p_asd))
        return 0;
  
      // Concatenate what was received until the final piece is found.
***************
*** 4539,4544 ****
--- 4533,4546 ----
        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;
*** ../vim-9.0.0234/src/version.c       2022-08-21 10:40:02.451903998 +0100
--- src/version.c       2022-08-21 11:36:58.376897508 +0100
***************
*** 733,734 ****
--- 733,736 ----
  {   /* Add new patch number below this line */
+ /**/
+     235,
  /**/

-- 
Time flies like an arrow.
Fruit flies like a banana.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220821103751.B6CA91C0B17%40moolenaar.net.

Raspunde prin e-mail lui