All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
2 Save g:ale_pattern_options
3 Save g:ale_pattern_options_enabled
5 Save b:ale_original_filetype
8 unlet! b:ale_file_changed
10 let g:ale_pattern_options_enabled = 1
11 let g:ale_pattern_options = {}
16 call ale#test#SetDirectory('/testplugin/test')
24 call ale#test#RestoreDirectory()
26 Execute(The pattern options function should work when there are no patterns):
27 call ale#test#SetFilename('foobar.js')
28 call ale#events#ReadOrEnterEvent(bufnr(''))
30 Execute(Buffer variables should be set when filename patterns match):
31 let g:ale_pattern_options = {
35 \ '&filetype': 'pattern_option_set_filetype',
39 call ale#test#SetFilename('foobar.js')
40 call ale#events#ReadOrEnterEvent(bufnr(''))
42 AssertEqual 0, b:ale_enabled
43 AssertEqual 0, b:some_option
45 call ale#test#SetFilename('bazboz.js')
46 call ale#events#ReadOrEnterEvent(bufnr(''))
48 AssertEqual 1, b:ale_enabled
49 AssertEqual 347, b:some_option
50 AssertEqual 'pattern_option_set_filetype', &filetype
52 Execute(Multiple pattern matches should be applied):
53 let g:ale_pattern_options = {
67 call ale#test#SetFilename('foobar.js')
68 call ale#events#ReadOrEnterEvent(bufnr(''))
70 AssertEqual 1, b:ale_enabled
71 AssertEqual 666, b:some_option
73 Execute(Patterns should not be applied when the setting is disabled):
74 let g:ale_pattern_options_enabled = 0
75 let g:ale_pattern_options = {'foo': {'some_option': 666}}
77 call ale#test#SetFilename('foobar.js')
78 call ale#events#ReadOrEnterEvent(bufnr(''))
80 AssertEqual 0, b:some_option
82 " This test is important for making sure we update the sorted items.
83 Execute(Patterns should be applied after the Dictionary changes):
84 call ale#test#SetFilename('foobar.js')
86 let g:ale_pattern_options = {}
88 call ale#events#ReadOrEnterEvent(bufnr(''))
90 AssertEqual 0, b:some_option
92 let g:ale_pattern_options['foo'] = {'some_option': 666}
94 call ale#events#ReadOrEnterEvent(bufnr(''))
96 AssertEqual 666, b:some_option
98 Execute(SetOptions should tolerate settings being unset):
99 " This might happen if ALE is loaded in a weird way, so tolerate it.
100 unlet! g:ale_pattern_options
101 unlet! g:ale_pattern_options_enabled
103 call ale#events#ReadOrEnterEvent(bufnr(''))
105 let g:ale_pattern_options_enabled = 1
107 call ale#events#ReadOrEnterEvent(bufnr(''))