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

Code before:
      {2:[No Name]  <en-dv>  }{3:[No Name]   <en-dv> }|
                                              |
    ]])

    command('set laststatus=3')
    screen:expect([[
                         │^                    |
      {1:~                  }│{1:~                   }|*5
      {3:[No Name]                       <en-dv> }|
                                              |
    ]])
  end)

  it("nested call from nvim_eval_statusline() doesn't overwrite items #32259", function()
    exec_lua('vim.o.laststatus = 2')
    exec_lua([[vim.o.statusline = '%#Special#B:%{nvim_eval_statusline("%f", []).str}']])
    screen:expect([[
      ^                                        |
      {1:~                                       }|*5
      {101:B:[No Name]                             }|
                                              |
    ]])
  end)
end)

describe('Default statusline', function()
  local screen

  before_each(function()
    clear()
    screen = Screen.new(60, 16)
    screen:add_extra_attr_ids {
      [100] = { foreground = Screen.colors.Magenta1, bold = true },
    }
    command('set laststatus=2')
    command('set ruler')
  end)

  it('setting statusline to empty string sets default statusline', function()
    exec_lua("vim.o.statusline = 'asdf'")
    eq('asdf', eval('&statusline'))

    local default_statusline =
      "%<%f %h%w%m%r %=%{% &showcmdloc == 'statusline' ? '%-10.S ' : '' %}%{% exists('b:keymap_name') ? '<'..b:keymap_name..'> ' : '' %}%{% &ruler ? ( &rulerformat == '' ? '%-14.(%l,%c%V%) %P' : &rulerformat ) : '' %}"

    exec_lua("vim.o.statusline = ''")

    eq(default_statusline, eval('&statusline'))

    screen:expect([[
      ^                                                            |

Review comment (suggestion):
```suggestion
describe('default statusline', function()
```

Code after:
      {2:[No Name]  <en-dv>  }{3:[No Name]   <en-dv> }|
                                              |
    ]])

    command('set laststatus=3')
    screen:expect([[
                         │^                    |
      {1:~                  }│{1:~                   }|*5
      {3:[No Name]                       <en-dv> }|
                                              |
    ]])
  end)

  it("nested call from nvim_eval_statusline() doesn't overwrite items #32259", function()
    exec_lua('vim.o.laststatus = 2')
    exec_lua([[vim.o.statusline = '%#Special#B:%{nvim_eval_statusline("%f", []).str}']])
    screen:expect([[
      ^                                        |
      {1:~                                       }|*5
      {101:B:[No Name]                             }|
                                              |
    ]])
  end)
end)

describe('default statusline', function()
  local screen

  before_each(function()
    clear()
    screen = Screen.new(60, 16)
    screen:add_extra_attr_ids {
      [100] = { foreground = Screen.colors.Magenta1, bold = true },
    }
    command('set laststatus=2')
    command('set ruler')
  end)

  it('setting statusline to empty string sets default statusline', function()
    exec_lua("vim.o.statusline = 'asdf'")
    eq('asdf', eval('&statusline'))

    local default_statusline =
      "%<%f %h%w%m%r %=%{% &showcmdloc == 'statusline' ? '%-10.S ' : '' %}%{% exists('b:keymap_name') ? '<'..b:keymap_name..'> ' : '' %}%{% &ruler ? ( &rulerformat == '' ? '%-14.(%l,%c%V%) %P' : &rulerformat ) : '' %}"

    exec_lua("vim.o.statusline = ''")

    eq(default_statusline, eval('&statusline'))

    screen:expect([[
      ^                                                            |