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

Code before:
    eq('fg', eval('synIDattr(hlID("Visual"), "bg#", "gui")'))
    eq('bg', eval('synIDattr(hlID("Visual"), "sp", "gui")'))
    eq('bg', eval('synIDattr(hlID("Visual"), "sp#", "gui")'))
  end)

  it('resolve to "Normal" values in RGB-capable UI', function()
    local _ = Screen.new(50, 7, { rgb = true })
    eq('bg', eval('synIDattr(hlID("Visual"), "fg")'))
    eq(eval('synIDattr(hlID("Normal"), "bg#")'), eval('synIDattr(hlID("Visual"), "fg#")'))
    eq('fg', eval('synIDattr(hlID("Visual"), "bg")'))
    eq(eval('synIDattr(hlID("Normal"), "fg#")'), eval('synIDattr(hlID("Visual"), "bg#")'))
    eq('bg', eval('synIDattr(hlID("Visual"), "sp")'))
    eq(eval('synIDattr(hlID("Normal"), "bg#")'), eval('synIDattr(hlID("Visual"), "sp#")'))
  end)

  it('resolve after the "Normal" group is modified', function()
    local _ = Screen.new(50, 7, { rgb = true })
    local new_guibg = '#282c34'
    local new_guifg = '#abb2bf'
    command('highlight Normal guifg=' .. new_guifg .. ' guibg=' .. new_guibg)
    eq(new_guibg, eval('synIDattr(hlID("Visual"), "fg#")'))
    eq(new_guifg, eval('synIDattr(hlID("Visual"), "bg#")'))
    eq(new_guibg, eval('synIDattr(hlID("Visual"), "sp#")'))
  end)

  it('refresh cmdline after MsgArea set #17832', function()
    local screen = Screen.new(50, 7, { rgb = true })
    command('set termguicolors')
    command('call nvim_set_hl(0, "MsgArea", {"fg": "Red"}) | echomsg "foo"')
    screen:expect({
      grid = [[
        ^                                                  |
        {1:~                                                 }|*5
        {19:foo                                               }|
      ]],
    })
  end)
end)


Review comment (bug):
This test description is useless and misleading. Is it about MsgArea specifically, or any highlight? Why is the test in the `describe('fg/bg special colors'` block? It seems like a more general bug, something like this (correct me if wrong):

```suggestion
  it('changed highlight is reflected in messages before redraw #17832', function()
```

Code after:
    eq('fg', eval('synIDattr(hlID("Visual"), "bg#", "gui")'))
    eq('bg', eval('synIDattr(hlID("Visual"), "sp", "gui")'))
    eq('bg', eval('synIDattr(hlID("Visual"), "sp#", "gui")'))
  end)

  it('resolve to "Normal" values in RGB-capable UI', function()
    local _ = Screen.new(50, 7, { rgb = true })
    eq('bg', eval('synIDattr(hlID("Visual"), "fg")'))
    eq(eval('synIDattr(hlID("Normal"), "bg#")'), eval('synIDattr(hlID("Visual"), "fg#")'))
    eq('fg', eval('synIDattr(hlID("Visual"), "bg")'))
    eq(eval('synIDattr(hlID("Normal"), "fg#")'), eval('synIDattr(hlID("Visual"), "bg#")'))
    eq('bg', eval('synIDattr(hlID("Visual"), "sp")'))
    eq(eval('synIDattr(hlID("Normal"), "bg#")'), eval('synIDattr(hlID("Visual"), "sp#")'))
  end)

  it('resolve after the "Normal" group is modified', function()
    local _ = Screen.new(50, 7, { rgb = true })
    local new_guibg = '#282c34'
    local new_guifg = '#abb2bf'
    command('highlight Normal guifg=' .. new_guifg .. ' guibg=' .. new_guibg)
    eq(new_guibg, eval('synIDattr(hlID("Visual"), "fg#")'))
    eq(new_guifg, eval('synIDattr(hlID("Visual"), "bg#")'))
    eq(new_guibg, eval('synIDattr(hlID("Visual"), "sp#")'))
  end)

  it('changed highlight is reflected in messages before redraw #17832', function()
    local screen = Screen.new(50, 7, { rgb = true })
    command('set termguicolors')
    -- :echomsg in the same request, before the next redraw.
    command('call nvim_set_hl(0, "MsgArea", {"fg": "Red"}) | echomsg "foo"')
    screen:expect({
      grid = [[
        ^                                                  |
        {1:~                                                 }|*5
        {19:foo                                               }|
      ]],
    })
  end)
end)