diff options
author | Jakob Schnitzer <mail@jakobschnitzer.de> | 2017-03-24 20:21:05 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-03-27 13:43:20 +0200 |
commit | 7bc37ffb22a84668bba5b2e3589c4c05ad43f7d0 (patch) | |
tree | 5934e78d1ad70956550df31298f571f9ff451890 /test/functional/terminal/scrollback_spec.lua | |
parent | 2b1398c31ea9ab9f4aaa40188f24d7e76a519e2d (diff) | |
download | rneovim-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 'test/functional/terminal/scrollback_spec.lua')
-rw-r--r-- | test/functional/terminal/scrollback_spec.lua | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index 81649f2bde..4ead288a19 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -8,6 +8,7 @@ local command = helpers.command local wait = helpers.wait local retry = helpers.retry local curbufmeths = helpers.curbufmeths +local nvim = helpers.nvim local feed_data = thelpers.feed_data if helpers.pending_win32(pending) then return end @@ -368,6 +369,12 @@ describe("'scrollback' option", function() clear() end) + local function set_fake_shell() + -- shell-test.c is a fake shell that prints its arguments and exits. + nvim('set_option', 'shell', nvim_dir..'/shell-test') + nvim('set_option', 'shellcmdflag', 'EXE') + end + local function expect_lines(expected, epsilon) local ep = epsilon and epsilon or 0 local actual = eval("line('$')") @@ -421,12 +428,13 @@ describe("'scrollback' option", function() screen:detach() end) - it('defaults to 1000', function() - execute('terminal') + it('defaults to 1000 in terminal buffers', function() + set_fake_shell() + command('terminal') eq(1000, curbufmeths.get_option('scrollback')) end) - it('error if set to invalid values', function() + it('error if set to invalid value', function() local status, rv = pcall(command, 'set scrollback=-2') eq(false, status) -- assert failure eq('E474:', string.match(rv, "E%d*:")) @@ -437,15 +445,32 @@ describe("'scrollback' option", function() end) it('defaults to -1 on normal buffers', function() - execute('new') + command('new') eq(-1, curbufmeths.get_option('scrollback')) end) - it('error if set on a normal buffer', function() + it(':setlocal in a normal buffer is an error', function() command('new') - execute('set scrollback=42') + execute('setlocal scrollback=42') feed('<CR>') eq('E474:', string.match(eval("v:errmsg"), "E%d*:")) + eq(-1, curbufmeths.get_option('scrollback')) + end) + + it(':set updates local value and global default', function() + set_fake_shell() + command('set scrollback=42') -- set global and (attempt) local + eq(-1, curbufmeths.get_option('scrollback')) -- normal buffer: -1 + command('terminal') + eq(42, curbufmeths.get_option('scrollback')) -- inherits global default + command('setlocal scrollback=99') + eq(99, curbufmeths.get_option('scrollback')) + command('set scrollback<') -- reset to global default + eq(42, curbufmeths.get_option('scrollback')) + command('setglobal scrollback=734') -- new global default + eq(42, curbufmeths.get_option('scrollback')) -- local value did not change + command('terminal') + eq(734, curbufmeths.get_option('scrollback')) end) end) |