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

Code before:
      :  echo input("foo\nbar:")                           |
      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):
this does not have `++nested` so the `set nowrap` itself will not trigger OptionSet, right? a bit confusing given the test context.

Code after:
      :  echo input("foo\nbar:")                           |
      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)