diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-08-21 11:37:17 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-08-21 11:37:17 +0100 |
commit | 474ad390ccb8bbeb53848122829e04c52f0349ce (patch) | |
tree | dfb5bfd980794d589a77b0964e3a6535e452a47a | |
parent | 8d69637133e17370491b83da8657a15b991c2f76 (diff) | |
download | vim-git-474ad390ccb8bbeb53848122829e04c52f0349ce.tar.gz |
patch 9.0.0235: 'autoshelldir' does not work with chunked resposev9.0.0235
Problem: 'autoshelldir' does not work with chunked respose.
Solution: Collect chunks before parsing OSC 7. (closes #10949)
-rw-r--r-- | src/terminal.c | 36 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 21 insertions, 17 deletions
diff --git a/src/terminal.c b/src/terminal.c index a95187005..c0fa1254e 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -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; diff --git a/src/version.c b/src/version.c index 07b571d8f..616f748c4 100644 --- a/src/version.c +++ b/src/version.c @@ -732,6 +732,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 235, +/**/ 234, /**/ 233, |