Repository: neovim/neovim
File: test/functional/ui/messages2_spec.lua (Lua)

Code before:
      foo                                                  |
      bar:^                                                 |
    ]])
    feed('<Esc>:endif')
    screen:expect([[
                                                           |
      {1:~                                                    }|*8
      {16::}{15:if} {26:1}                                                |
      {16::}  {15:echo} {25:input}{16:(}{26:"foo\nbar:"}{16:)}                           |
      {15:baz}                                                  |
      {16::}  {15:echo} {25:input}{16:(}{26:"foo\nbar:"}{16:)}                           |
      {16::}  {16::}{15:endif}^                                            |
    ]])
    feed('<CR>')
    screen:expect([[
      ^                                                     |
      {1:~                                                    }|*12
                                                           |
    ]])
  end)

  it('FileType is fired after default options are set', function()
    n.exec([[
      let g:optionset = 0
      au FileType pager set nowrap
      au OptionSet * let g:optionset += 1
      echom 'foo'->repeat(&columns)
      messages
    ]])
    screen:expect([[
                                                           |
      {1:~                                                    }|*9
      {3:─────────────────────────────────────────────────────}|
      ^foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofo|
      {1:                                                     }|
                                                           |
    ]])
    t.eq(4, n.eval('g:optionset')) -- still fires for 'filetype'
  end)
end)


Review comment (suggestion):
for extra visibility is it worth tracking the option name? kind of curious which (4...) options are being set. 

```suggestion
      let g:optionset = ''
      au FileType pager set nowrap
      au OptionSet * let g:optionset ..= expand('<amatch>') .. ','
```

Code after:
      foo                                                  |
      bar:^                                                 |
    ]])
    feed('<Esc>:endif')
    screen:expect([[
                                                           |
      {1:~                                                    }|*8
      {16::}{15:if} {26:1}                                                |
      {16::}  {15:echo} {25:input}{16:(}{26:"foo\nbar:"}{16:)}                           |
      {15:baz}                                                  |
      {16::}  {15:echo} {25:input}{16:(}{26:"foo\nbar:"}{16:)}                           |
      {16::}  {16::}{15:endif}^                                            |
    ]])
    feed('<CR>')
    screen:expect([[
      ^                                                     |
      {1:~                                                    }|*12
                                                           |
    ]])
  end)

  it('FileType is fired after default options are set', function()
    n.exec([[
      let g:set = {}
      au FileType pager set nowrap
      au OptionSet * let g:set[expand('<amatch>')] = g:set->get(expand('<amatch>'), 0) + 1
      echom 'foo'->repeat(&columns)
      messages
    ]])
    screen:expect([[
                                                           |
      {1:~                                                    }|*9
      {3:─────────────────────────────────────────────────────}|
      ^foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofo|
      {1:                                                     }|
                                                           |
    ]])
    t.eq({ filetype = 4 }, n.eval('g:set')) -- still fires for 'filetype'
  end)
end)