diff options
author | Marco Hinz <mh.codebro+github@gmail.com> | 2019-02-04 02:53:23 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-02-04 02:53:23 +0100 |
commit | 91688b488310ae45ea5874df8729e7dfe554c0bc (patch) | |
tree | 01b240279dd6369adeb782a73902f9ecab9516e6 /src/nvim/terminal.c | |
parent | 70f6939fd4b5e0f03dc606eedae13ef28fc0f9dd (diff) | |
download | rneovim-91688b488310ae45ea5874df8729e7dfe554c0bc.tar.gz rneovim-91688b488310ae45ea5874df8729e7dfe554c0bc.tar.bz2 rneovim-91688b488310ae45ea5874df8729e7dfe554c0bc.zip |
options: set 'scrollback' to -1 by default #9563
Makes the 'scrollback' option more consistent (same default for all buffers) and future-proof.
- Default to -1 for all buffers, but treat it as an implementation detail.
- Document range of 1 - 100_000.
- New terminal buffer by default sets scrollback=10_000 if the global default is -1.
- Existing terminal buffer: On entering terminal-mode or on refresh, if the user explicitly did `:set[local] scbk=-1`, the local value goes to 100_000 (max). (This is undocumented on purpose. Users should work with explicit values in the range of 1-100_000.)
Diffstat (limited to 'src/nvim/terminal.c')
-rw-r--r-- | src/nvim/terminal.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 33050ac642..5d8c29a5ad 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -236,7 +236,7 @@ Terminal *terminal_open(TerminalOptions opts) // Default settings for terminal buffers curbuf->b_p_ma = false; // 'nomodifiable' curbuf->b_p_ul = -1; // 'undolevels' - curbuf->b_p_scbk = p_scbk; // 'scrollback' + curbuf->b_p_scbk = (p_scbk == -1) ? 10000 : MAX(1, p_scbk); // 'scrollback' curbuf->b_p_tw = 0; // 'textwidth' set_option_value("wrap", false, NULL, OPT_LOCAL); set_option_value("list", false, NULL, OPT_LOCAL); @@ -249,8 +249,7 @@ Terminal *terminal_open(TerminalOptions opts) apply_autocmds(EVENT_TERMOPEN, NULL, NULL, false, curbuf); // Configure the scrollback buffer. - rv->sb_size = curbuf->b_p_scbk < 0 - ? SB_MAX : (size_t)MAX(1, curbuf->b_p_scbk); + rv->sb_size = (size_t)curbuf->b_p_scbk; rv->sb_buffer = xmalloc(sizeof(ScrollbackLine *) * rv->sb_size); if (!true_color) { @@ -1162,8 +1161,10 @@ static void refresh_size(Terminal *term, buf_T *buf) /// Adjusts scrollback storage after 'scrollback' option changed. static void on_scrollback_option_changed(Terminal *term, buf_T *buf) { - const size_t scbk = curbuf->b_p_scbk < 0 - ? SB_MAX : (size_t)MAX(1, curbuf->b_p_scbk); + if (buf->b_p_scbk < 1) { + buf->b_p_scbk = SB_MAX; + } + const size_t scbk = (size_t)buf->b_p_scbk; assert(term->sb_current < SIZE_MAX); if (term->sb_pending > 0) { // Pending rows must be processed first. abort(); |