summaryrefslogtreecommitdiff
path: root/src/terminal.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-11-15 17:13:11 +0000
committerBram Moolenaar <Bram@vim.org>2021-11-15 17:13:11 +0000
commit36968af1558b295b5fdf56973d5dcc75fce85658 (patch)
tree259b9d8f69ffa351df4dc74273346a1f71394f6f /src/terminal.c
parent733b124a9098d5e2f028fd2e12012b831c9e9024 (diff)
downloadvim-git-36968af1558b295b5fdf56973d5dcc75fce85658.tar.gz
patch 8.2.3597: Vim seems to hang when writing a long text to a terminalv8.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)
Diffstat (limited to 'src/terminal.c')
-rw-r--r--src/terminal.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/terminal.c b/src/terminal.c
index 1adf690ad..fb8b2881f 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -1130,10 +1130,24 @@ get_tty_part(term_T *term UNUSED)
* Write job output "msg[len]" to the vterm.
*/
static void
-term_write_job_output(term_T *term, char_u *msg, size_t len)
+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);