To: vim_dev@googlegroups.com Subject: Patch 8.2.3597 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3597 Problem: Vim seems to hang when writing a very long text to a terminal window. Solution: Limit the amount of text based on 'termwinscroll'. (issue #9080) Files: runtime/doc/options.txt, src/terminal.c *** ../vim-8.2.3596/runtime/doc/options.txt 2021-10-17 14:13:04.832665843 +0100 --- runtime/doc/options.txt 2021-11-15 17:03:13.711203491 +0000 *************** *** 7919,7924 **** --- 7941,7949 ---- Number of scrollback lines to keep. When going over this limit the first 10% of the scrollback lines are deleted. This is just to reduce the memory usage. See |Terminal-Normal|. + Also used as a limit for text sent to the terminal in one write, + multiplied by the number of columns times 3 (average number of bytes + per cell). *'termwinsize'* *'tws'* 'termwinsize' 'tws' string (default "") *** ../vim-8.2.3596/src/terminal.c 2021-11-12 16:01:11.948325522 +0000 --- src/terminal.c 2021-11-15 17:10:25.198600741 +0000 *************** *** 1130,1139 **** * Write job output "msg[len]" to the vterm. */ static void ! term_write_job_output(term_T *term, char_u *msg, size_t len) { VTerm *vterm = term->tl_vterm; size_t prevlen = vterm_output_get_buffer_current(vterm); vterm_input_write(vterm, (char *)msg, len); --- 1130,1153 ---- * Write job output "msg[len]" to the vterm. */ static void ! term_write_job_output(term_T *term, char_u *msg_arg, size_t len_arg) { + char_u *msg = msg_arg; + size_t len = len_arg; VTerm *vterm = term->tl_vterm; size_t prevlen = vterm_output_get_buffer_current(vterm); + size_t limit = term->tl_buffer->b_p_twsl * term->tl_cols * 3; + + // Limit the length to 'termwinscroll' * cols * 3 bytes. Keep the text at + // the end. + if (len > limit) + { + char_u *p = msg + len - limit; + + p -= (*mb_head_off)(msg, p); + len -= p - msg; + msg = p; + } vterm_input_write(vterm, (char *)msg, len); *** ../vim-8.2.3596/src/version.c 2021-11-15 11:22:05.059277981 +0000 --- src/version.c 2021-11-15 17:11:37.442499072 +0000 *************** *** 759,760 **** --- 759,762 ---- { /* Add new patch number below this line */ + /**/ + 3597, /**/ -- Individualists unite! /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///