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

Code before:
    command('vnew')
    command('call setline(1, ["foo", "foo", "bar"])')
    command('windo diffthis')
    command('1wincmd w')
    screen:expect([[
      {7:  }{8:    }{23:-------------------}│{7:  }{8:  1 }{22:baz               }|
      {7:  }{100:  1 }{9:^foo                }│{7:  }{100:  2 }{9:foo               }|
      {7:  }{8:  2 }foo                │{7:  }{8:  3 }foo               |
      {7:  }{8:  3 }bar                │{7:  }{8:  4 }bar               |
      {1:~                        }│{1:~                       }|*6
      {3:[No Name] [+]             }{2:[No Name] [+]           }|
                                                        |
    ]])
    command('set cursorlineopt=number')
    screen:expect([[
      {7:  }{8:    }{23:-------------------}│{7:  }{8:  1 }{22:baz               }|
      {7:  }{100:  1 }^foo                │{7:  }{100:  2 }{9:foo               }|
      {7:  }{8:  2 }foo                │{7:  }{8:  3 }foo               |
      {7:  }{8:  3 }bar                │{7:  }{8:  4 }bar               |
      {1:~                        }│{1:~                       }|*6
      {3:[No Name] [+]             }{2:[No Name] [+]           }|
                                                        |
    ]])
  end)

  it('CursorLine works with highlight groups linked to Normal', function()
    local screen = Screen.new(50, 12)
    screen:add_extra_attr_ids({
      [101] = { background = Screen.colors.Grey90, foreground = Screen.colors.Gray100 },
    })
    command('hi Normal guibg=black guifg=white')
    command('hi def link Test Normal')
    feed('ifoo bar<ESC>')
    feed(':call matchadd("Test", "bar")<cr>')
    command('set cursorline')
    screen:expect([[
      {21:foo }{101:ba^r}{21:                                           }|
      {1:~                                                 }|*10
      :call matchadd("Test", "bar")                     |
    ]])
  end)
end)

describe('CursorColumn highlight', function()
  local screen
  before_each(function()
    clear()
    screen = Screen.new(50, 8)
    screen:add_extra_attr_ids {
      [100] = { background = Screen.colors.Blue1 },
    }

Review comment (suggestion):
should this say "overrides" or "overlays"? "works with" is vague.
```suggestion
  it('CursorLine overlays hl group linked to Normal', function()
```

Code after:
    command('vnew')
    command('call setline(1, ["foo", "foo", "bar"])')
    command('windo diffthis')
    command('1wincmd w')
    screen:expect([[
      {7:  }{8:    }{23:-------------------}│{7:  }{8:  1 }{22:baz               }|
      {7:  }{100:  1 }{9:^foo                }│{7:  }{100:  2 }{9:foo               }|
      {7:  }{8:  2 }foo                │{7:  }{8:  3 }foo               |
      {7:  }{8:  3 }bar                │{7:  }{8:  4 }bar               |
      {1:~                        }│{1:~                       }|*6
      {3:[No Name] [+]             }{2:[No Name] [+]           }|
                                                        |
    ]])
    command('set cursorlineopt=number')
    screen:expect([[
      {7:  }{8:    }{23:-------------------}│{7:  }{8:  1 }{22:baz               }|
      {7:  }{100:  1 }^foo                │{7:  }{100:  2 }{9:foo               }|
      {7:  }{8:  2 }foo                │{7:  }{8:  3 }foo               |
      {7:  }{8:  3 }bar                │{7:  }{8:  4 }bar               |
      {1:~                        }│{1:~                       }|*6
      {3:[No Name] [+]             }{2:[No Name] [+]           }|
                                                        |
    ]])
  end)

  it('CursorLine overlays hl group linked to Normal', function()
    local screen = Screen.new(50, 12)
    screen:add_extra_attr_ids({
      [101] = { background = Screen.colors.Grey90, foreground = Screen.colors.Gray100 },
    })
    command('hi Normal guibg=black guifg=white')
    command('hi def link Test Normal')
    feed('ifoo bar<ESC>')
    feed(':call matchadd("Test", "bar")<cr>')
    command('set cursorline')
    screen:expect([[
      {21:foo }{101:ba^r}{21:                                           }|
      {1:~                                                 }|*10
      :call matchadd("Test", "bar")                     |
    ]])
  end)
end)

describe('CursorColumn highlight', function()
  local screen
  before_each(function()
    clear()
    screen = Screen.new(50, 8)
    screen:add_extra_attr_ids {
      [100] = { background = Screen.colors.Blue1 },
    }