Mercurial > vim
diff src/terminal.c @ 13680:c32e9628dc30 v8.0.1712
patch 8.0.1712: terminal scrollback is not limited
commit https://github.com/vim/vim/commit/8c041b6b95f49f7383cf00e2036cf009b326fa8d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 14 18:14:06 2018 +0200
patch 8.0.1712: terminal scrollback is not limited
Problem: Terminal scrollback is not limited.
Solution: Add the 'terminalscroll' option.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 14 Apr 2018 18:15:06 +0200 |
parents | 39fcaaa973db |
children | 1651a4c5c27a |
line wrap: on
line diff
--- a/src/terminal.c +++ b/src/terminal.c @@ -40,8 +40,6 @@ * TODO: * - Win32: Make terminal used for :!cmd in the GUI work better. Allow for * redirection. Probably in call to channel_set_pipes(). - * - add an optional limit for the scrollback size. When reaching it remove - * 10% at the start. * - Copy text in the vterm to the Vim buffer once in a while, so that * completion works. * - in GUI vertical split causes problems. Cursor is flickering. (Hirohito @@ -2518,7 +2516,27 @@ handle_pushline(int cols, const VTermScr { term_T *term = (term_T *)user; - /* TODO: Limit the number of lines that are stored. */ + /* If the number of lines that are stored goes over 'termscrollback' then + * delete the first 10%. */ + if (term->tl_scrollback.ga_len > p_tlsl) + { + int todo = p_tlsl / 10; + int i; + + curbuf = term->tl_buffer; + for (i = 0; i < todo; ++i) + { + vim_free(((sb_line_T *)term->tl_scrollback.ga_data + i)->sb_cells); + ml_delete(1, FALSE); + } + curbuf = curwin->w_buffer; + + term->tl_scrollback.ga_len -= todo; + mch_memmove(term->tl_scrollback.ga_data, + (sb_line_T *)term->tl_scrollback.ga_data + todo, + sizeof(sb_line_T) * term->tl_scrollback.ga_len); + } + if (ga_grow(&term->tl_scrollback, 1) == OK) { cellattr_T *p = NULL;