comparison src/terminal.c @ 20494:4f6904d8b258 v8.2.0801

patch 8.2.0801: terminal test fails on Mac Commit: https://github.com/vim/vim/commit/eaa3e0dae53acc9a345f430ef014d65c105192c3 Author: Bram Moolenaar <Bram@vim.org> Date: Tue May 19 23:11:00 2020 +0200 patch 8.2.0801: terminal test fails on Mac Problem: Terminal test fails on Mac. Solution: Concatenate OSC pieces.
author Bram Moolenaar <Bram@vim.org>
date Tue, 19 May 2020 23:15:03 +0200
parents 1d595fada804
children 747a270eb1db
comparison
equal deleted inserted replaced
20493:39b0887c7768 20494:4f6904d8b258
160 int tl_cursor_blink; 160 int tl_cursor_blink;
161 int tl_cursor_shape; // 1: block, 2: underline, 3: bar 161 int tl_cursor_shape; // 1: block, 2: underline, 3: bar
162 char_u *tl_cursor_color; // NULL or allocated 162 char_u *tl_cursor_color; // NULL or allocated
163 163
164 int tl_using_altscreen; 164 int tl_using_altscreen;
165 garray_T tl_osc_buf; // incomplete OSC string
165 }; 166 };
166 167
167 #define TMODE_ONCE 1 // CTRL-\ CTRL-N used 168 #define TMODE_ONCE 1 // CTRL-\ CTRL-N used
168 #define TMODE_LOOP 2 // CTRL-W N used 169 #define TMODE_LOOP 2 // CTRL-W N used
169 170
443 #ifdef FEAT_GUI 444 #ifdef FEAT_GUI
444 term->tl_system = (flags & TERM_START_SYSTEM); 445 term->tl_system = (flags & TERM_START_SYSTEM);
445 #endif 446 #endif
446 ga_init2(&term->tl_scrollback, sizeof(sb_line_T), 300); 447 ga_init2(&term->tl_scrollback, sizeof(sb_line_T), 300);
447 ga_init2(&term->tl_scrollback_postponed, sizeof(sb_line_T), 300); 448 ga_init2(&term->tl_scrollback_postponed, sizeof(sb_line_T), 300);
449 ga_init2(&term->tl_osc_buf, sizeof(char), 300);
448 450
449 CLEAR_FIELD(split_ea); 451 CLEAR_FIELD(split_ea);
450 if (opt->jo_curwin) 452 if (opt->jo_curwin)
451 { 453 {
452 // Create a new buffer in the current window. 454 // Create a new buffer in the current window.
1013 term_T *term = terminals_to_free; 1015 term_T *term = terminals_to_free;
1014 1016
1015 terminals_to_free = term->tl_next; 1017 terminals_to_free = term->tl_next;
1016 1018
1017 free_scrollback(term); 1019 free_scrollback(term);
1020 ga_clear(&term->tl_osc_buf);
1018 1021
1019 term_free_vterm(term); 1022 term_free_vterm(term);
1020 vim_free(term->tl_api); 1023 vim_free(term->tl_api);
1021 vim_free(term->tl_title); 1024 vim_free(term->tl_title);
1022 #ifdef FEAT_SESSION 1025 #ifdef FEAT_SESSION
4200 term_T *term = (term_T *)user; 4203 term_T *term = (term_T *)user;
4201 js_read_T reader; 4204 js_read_T reader;
4202 typval_T tv; 4205 typval_T tv;
4203 channel_T *channel = term->tl_job == NULL ? NULL 4206 channel_T *channel = term->tl_job == NULL ? NULL
4204 : term->tl_job->jv_channel; 4207 : term->tl_job->jv_channel;
4208 garray_T *gap = &term->tl_osc_buf;
4205 4209
4206 // We recognize only OSC 5 1 ; {command} 4210 // We recognize only OSC 5 1 ; {command}
4207 if (command != 51) 4211 if (command != 51)
4208 return 0; 4212 return 0;
4209 4213
4210 reader.js_buf = vim_strnsave((char_u *)frag.str, (int)(frag.len)); 4214 // Concatenate what was received until the final piece is found.
4211 if (reader.js_buf == NULL) 4215 if (ga_grow(gap, (int)frag.len + 1) == FAIL)
4216 {
4217 ga_clear(gap);
4212 return 1; 4218 return 1;
4219 }
4220 mch_memmove((char *)gap->ga_data + gap->ga_len, frag.str, frag.len);
4221 gap->ga_len += frag.len;
4222 if (!frag.final)
4223 return 1;
4224
4225 ((char *)gap->ga_data)[gap->ga_len] = 0;
4226 reader.js_buf = gap->ga_data;
4213 reader.js_fill = NULL; 4227 reader.js_fill = NULL;
4214 reader.js_used = 0; 4228 reader.js_used = 0;
4215 if (json_decode(&reader, &tv, 0) == OK 4229 if (json_decode(&reader, &tv, 0) == OK
4216 && tv.v_type == VAR_LIST 4230 && tv.v_type == VAR_LIST
4217 && tv.vval.v_list != NULL) 4231 && tv.vval.v_list != NULL)
4241 } 4255 }
4242 } 4256 }
4243 else 4257 else
4244 ch_log(channel, "Invalid JSON received"); 4258 ch_log(channel, "Invalid JSON received");
4245 4259
4246 vim_free(reader.js_buf); 4260 ga_clear(gap);
4247 clear_tv(&tv); 4261 clear_tv(&tv);
4248 return 1; 4262 return 1;
4249 } 4263 }
4250 4264
4251 /* 4265 /*