From 7c4bb23ff38a459911a742657572bc273e528ddf Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 3 Jan 2018 19:57:22 +0100 Subject: defaults: do :filetype stuff unless explicitly "off" Until now, the default `:filetype ...` setup was skipped if the user config touched `:filetype` in any way (including implicitly via `:syntax on`). No one needs that, and it's very confusing. Instead, proceed with `:filetype ... on` unless the user explicitly called `:filetype ... off`. closes #7765 --- test/functional/options/defaults_spec.lua | 90 +++++++++++++++++-------------- 1 file changed, 50 insertions(+), 40 deletions(-) (limited to 'test/functional/options/defaults_spec.lua') diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index b83b7b8eee..fd232cb4dd 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -11,15 +11,6 @@ local neq = helpers.neq local mkdir = helpers.mkdir local rmdir = helpers.rmdir -local function init_session(...) - local args = { helpers.nvim_prog, '-i', 'NONE', '--embed', - '--cmd', helpers.nvim_set } - for _, v in ipairs({...}) do - table.insert(args, v) - end - helpers.set_session(helpers.spawn(args)) -end - describe('startup defaults', function() describe(':filetype', function() if helpers.pending_win32(pending) then return end @@ -36,50 +27,70 @@ describe('startup defaults', function() ) end - it('enabled by `-u NORC`', function() - init_session('-u', 'NORC') + it('all ON after `-u NORC`', function() + clear('-u', 'NORC') expect_filetype( 'filetype detection:ON plugin:ON indent:ON |') end) - it('disabled by `-u NONE`', function() - init_session('-u', 'NONE') + it('all ON after `:syntax …` #7765', function() + clear('-u', 'NORC', '--cmd', 'syntax on') expect_filetype( - 'filetype detection:OFF plugin:OFF indent:OFF |') + 'filetype detection:ON plugin:ON indent:ON |') + clear('-u', 'NORC', '--cmd', 'syntax off') + expect_filetype( + 'filetype detection:ON plugin:ON indent:ON |') end) - it('overridden by early `filetype on`', function() - init_session('-u', 'NORC', '--cmd', 'filetype on') + it('all OFF after `-u NONE`', function() + clear('-u', 'NONE') expect_filetype( - 'filetype detection:ON plugin:OFF indent:OFF |') + 'filetype detection:OFF plugin:OFF indent:OFF |') end) - it('overridden by early `filetype plugin on`', function() - init_session('-u', 'NORC', '--cmd', 'filetype plugin on') + it('explicit OFF stays OFF', function() + clear('-u', 'NORC', '--cmd', + 'syntax off | filetype off | filetype plugin indent off') + expect_filetype( + 'filetype detection:OFF plugin:OFF indent:OFF |') + clear('-u', 'NORC', '--cmd', 'syntax off | filetype plugin indent off') + expect_filetype( + 'filetype detection:ON plugin:OFF indent:OFF |') + clear('-u', 'NORC', '--cmd', 'filetype indent off') expect_filetype( 'filetype detection:ON plugin:ON indent:OFF |') + clear('-u', 'NORC', '--cmd', 'syntax off | filetype off') + expect_filetype( + 'filetype detection:OFF plugin:(on) indent:(on) |') + -- Swap the order. + clear('-u', 'NORC', '--cmd', 'filetype off | syntax off') + expect_filetype( + 'filetype detection:OFF plugin:(on) indent:(on) |') end) - it('overridden by early `filetype indent on`', function() - init_session('-u', 'NORC', '--cmd', 'filetype indent on') + it('all ON after early `:filetype … on`', function() + -- `:filetype … on` should not change the defaults. #7765 + -- Only an explicit `:filetype … off` sets OFF. + + clear('-u', 'NORC', '--cmd', 'filetype on') expect_filetype( - 'filetype detection:ON plugin:OFF indent:ON |') + 'filetype detection:ON plugin:ON indent:ON |') + clear('-u', 'NORC', '--cmd', 'filetype plugin on') + expect_filetype( + 'filetype detection:ON plugin:ON indent:ON |') + clear('-u', 'NORC', '--cmd', 'filetype indent on') + expect_filetype( + 'filetype detection:ON plugin:ON indent:ON |') end) - it('adjusted by late `filetype off`', function() - init_session('-u', 'NORC', '-c', 'filetype off') + it('late `:filetype … off` stays OFF', function() + clear('-u', 'NORC', '-c', 'filetype off') expect_filetype( 'filetype detection:OFF plugin:(on) indent:(on) |') - end) - - it('adjusted by late `filetype plugin off`', function() - init_session('-u', 'NORC', '-c', 'filetype plugin off') + clear('-u', 'NORC', '-c', 'filetype plugin off') expect_filetype( 'filetype detection:ON plugin:OFF indent:ON |') - end) - - it('adjusted by late `filetype indent off`', function() - init_session('-u', 'NORC', '-c', 'filetype indent off') + clear('-u', 'NORC', '-c', 'filetype indent off') expect_filetype( 'filetype detection:ON plugin:ON indent:OFF |') end) @@ -87,22 +98,21 @@ describe('startup defaults', function() describe('syntax', function() it('enabled by `-u NORC`', function() - init_session('-u', 'NORC') + clear('-u', 'NORC') eq(1, eval('g:syntax_on')) end) it('disabled by `-u NONE`', function() - init_session('-u', 'NONE') + clear('-u', 'NONE') eq(0, eval('exists("g:syntax_on")')) end) - it('overridden by early `syntax off`', function() - init_session('-u', 'NORC', '--cmd', 'syntax off') + it('`:syntax off` stays off', function() + -- early + clear('-u', 'NORC', '--cmd', 'syntax off') eq(0, eval('exists("g:syntax_on")')) - end) - - it('adjusted by late `syntax off`', function() - init_session('-u', 'NORC', '-c', 'syntax off') + -- late + clear('-u', 'NORC', '-c', 'syntax off') eq(0, eval('exists("g:syntax_on")')) end) end) -- cgit From 7311fb7cadff49422a15d3a40d7014000c8f4385 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 19 Oct 2017 17:26:03 -0400 Subject: win: enable more functional tests - plugin/shada_spec.lua: Use \r\n as Windows EOL for tests on BufWriteCmd, FileWriteCmd, FileAppendCmd. Alternative is 'set fileformat=unix'. --- test/functional/options/defaults_spec.lua | 2 -- 1 file changed, 2 deletions(-) (limited to 'test/functional/options/defaults_spec.lua') diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index b83b7b8eee..68e94d1a85 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -22,8 +22,6 @@ end describe('startup defaults', function() describe(':filetype', function() - if helpers.pending_win32(pending) then return end - local function expect_filetype(expected) local screen = Screen.new(50, 4) screen:attach() -- cgit From 384a39479a0b70abf9cd6ced0b5f1d53cd817c11 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Fri, 9 Feb 2018 08:44:24 +0900 Subject: 'fillchars': fix defaults logic; handle ambiwidth=double #7986 Update tests. --- test/functional/options/defaults_spec.lua | 36 ++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'test/functional/options/defaults_spec.lua') diff --git a/test/functional/options/defaults_spec.lua b/test/functional/options/defaults_spec.lua index 89d4e56d04..9e29baba2d 100644 --- a/test/functional/options/defaults_spec.lua +++ b/test/functional/options/defaults_spec.lua @@ -7,6 +7,7 @@ local command = helpers.command local clear = helpers.clear local eval = helpers.eval local eq = helpers.eq +local insert = helpers.insert local neq = helpers.neq local mkdir = helpers.mkdir local rmdir = helpers.rmdir @@ -115,7 +116,40 @@ describe('startup defaults', function() end) end) - describe('packpath', function() + describe("'fillchars'", function() + it('vert/fold flags', function() + clear() + local screen = Screen.new(50, 5) + screen:attach() + command('set laststatus=0') + insert([[ + 1 + 2 + 3 + 4]]) + command('normal! ggjzfj') + command('vsp') + screen:expect([[ + 1 │1 | + ^+-- 2 lines: 2··········│+-- 2 lines: 2·········| + 4 │4 | + ~ │~ | + | + ]]) + + -- ambiwidth=double defaults to single-byte fillchars. + command('set ambiwidth=double') + screen:expect([[ + 1 |1 | + ^+-- 2 lines: 2----------|+-- 2 lines: 2---------| + 4 |4 | + ~ |~ | + | + ]]) + end) + end) + + describe("'packpath'", function() it('defaults to &runtimepath', function() eq(meths.get_option('runtimepath'), meths.get_option('packpath')) end) -- cgit