aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/option.c
diff options
context:
space:
mode:
authorJakob Schnitzer <mail@jakobschnitzer.de>2017-03-24 20:21:05 +0100
committerJustin M. Keyes <justinkz@gmail.com>2017-03-27 13:43:20 +0200
commit7bc37ffb22a84668bba5b2e3589c4c05ad43f7d0 (patch)
tree5934e78d1ad70956550df31298f571f9ff451890 /src/nvim/option.c
parent2b1398c31ea9ab9f4aaa40188f24d7e76a519e2d (diff)
downloadrneovim-7bc37ffb22a84668bba5b2e3589c4c05ad43f7d0.tar.gz
rneovim-7bc37ffb22a84668bba5b2e3589c4c05ad43f7d0.tar.bz2
rneovim-7bc37ffb22a84668bba5b2e3589c4c05ad43f7d0.zip
terminal: global 'scrollback' #6352
Make the 'scrollback' option work like most other buffer-local options: - `:set scrollback=x` sets the global and local value - `:setglobal scrollback=x` sets only the global default - new terminal buffers inherit the global Normal buffers are still always -1, and :setlocal there is an error. Closes #6337
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r--src/nvim/option.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 2a17ca69d1..b037b0ae35 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -156,7 +156,6 @@ static long p_ts;
static long p_tw;
static int p_udf;
static long p_wm;
-static long p_scbk;
static char_u *p_keymap;
/* Saved values for when 'bin' is set. */
@@ -4199,16 +4198,13 @@ set_num_option (
FOR_ALL_TAB_WINDOWS(tp, wp) {
check_colorcolumn(wp);
}
- } else if (pp == &curbuf->b_p_scbk) {
+ } else if (pp == &curbuf->b_p_scbk || pp == &p_scbk) {
// 'scrollback'
- if (!curbuf->terminal) {
+ if (*pp < -1 || *pp > SB_MAX
+ || (opt_flags == OPT_LOCAL && !curbuf->terminal)) {
errmsg = e_invarg;
- curbuf->b_p_scbk = -1;
- } else {
- if (curbuf->b_p_scbk < -1 || curbuf->b_p_scbk > 100000) {
- errmsg = e_invarg;
- curbuf->b_p_scbk = 1000;
- }
+ *pp = old_value;
+ } else if (curbuf->terminal) {
// Force the scrollback to take effect.
terminal_resize(curbuf->terminal, UINT16_MAX, UINT16_MAX);
}
@@ -4331,6 +4327,11 @@ set_num_option (
if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0)
*(long *)get_varp_scope(&(options[opt_idx]), OPT_GLOBAL) = *pp;
+ if (pp == &curbuf->b_p_scbk && !curbuf->terminal) {
+ // Normal buffer: reset local 'scrollback' after updating the global value.
+ curbuf->b_p_scbk = -1;
+ }
+
options[opt_idx].flags |= P_WAS_SET;
if (!starting && errmsg == NULL) {
@@ -4586,7 +4587,7 @@ get_option_value (
//
// Pretends that option is absent if it is not present in the requested scope
// (i.e. has no global, window-local or buffer-local value depending on
-// opt_type). Uses
+// opt_type).
//
// Returned flags:
// 0 hidden or unknown option, also option that does not have requested