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

Code before:

  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 (suggestion):
```suggestion
    -- :echomsg in the same request, before the next redraw.
    command('call nvim_set_hl(0, "MsgArea", {"fg": "Red"}) | echomsg "foo"')
```

Code after:

  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)