Repository: neovim/neovim
File: test/functional/api/window_spec.lua (Lua)

Code before:
      command('let &winwidth = &columns | let &winminwidth = &columns')
      matches(
        'E36: Not enough room$',
        pcall_err(api.nvim_win_set_config, t2_cur_win, { split = 'left', win = 0 })
      )
      eq(t2_cur_win, api.nvim_tabpage_get_win(t2))
      command('set winminwidth& winwidth&')

      -- But is changed if successfully moved to a different tabpage.
      api.nvim_win_set_config(t2_cur_win, { split = 'left', win = 0 })
      eq(t2_alt_win, api.nvim_tabpage_get_win(t2))
      eq(t1, api.nvim_win_get_tabpage(t2_cur_win))

      -- Now do it for a float, which has different altwin logic.
      command('tabnext')
      t2_cur_win =
        api.nvim_open_win(0, true, { relative = 'editor', row = 5, col = 5, width = 5, height = 5 })
      eq(t2_alt_win, fn.win_getid(fn.winnr('#')))
      command('tabprevious')
      eq(t2_cur_win, api.nvim_tabpage_get_win(t2))

      api.nvim_win_set_config(t2_cur_win, { split = 'left', win = 0 })
      eq(t2_alt_win, api.nvim_tabpage_get_win(t2))
      eq(t1, api.nvim_win_get_tabpage(t2_cur_win))
    end)
    it('allow same "noautocmd" value when reconfig #36409', function()
      local cfg = { relative = 'editor', row = 1, col = 1, height = 2, width = 2, noautocmd = true }
      local win = api.nvim_open_win(0, false, cfg)
      cfg.height = 10
      eq(true, pcall(api.nvim_win_set_config, win, cfg))
      cfg.noautocmd = false
      eq(
        "'noautocmd' cannot be changed with existing windows",
        pcall_err(api.nvim_win_set_config, win, cfg)
      )
    end)
  end)

  describe('get_config', function()
    it('includes border', function()
      local b = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' }
      local win = api.nvim_open_win(0, true, {
        relative = 'win',
        row = 3,
        col = 3,
        width = 12,
        height = 3,
        border = b,
      })

      local cfg = api.nvim_win_get_config(win)

Review comment (suggestion):
```suggestion

    it('set_config cannot change "noautocmd" #36409', function()
```

Code after:
      command('let &winwidth = &columns | let &winminwidth = &columns')
      matches(
        'E36: Not enough room$',
        pcall_err(api.nvim_win_set_config, t2_cur_win, { split = 'left', win = 0 })
      )
      eq(t2_cur_win, api.nvim_tabpage_get_win(t2))
      command('set winminwidth& winwidth&')

      -- But is changed if successfully moved to a different tabpage.
      api.nvim_win_set_config(t2_cur_win, { split = 'left', win = 0 })
      eq(t2_alt_win, api.nvim_tabpage_get_win(t2))
      eq(t1, api.nvim_win_get_tabpage(t2_cur_win))

      -- Now do it for a float, which has different altwin logic.
      command('tabnext')
      t2_cur_win =
        api.nvim_open_win(0, true, { relative = 'editor', row = 5, col = 5, width = 5, height = 5 })
      eq(t2_alt_win, fn.win_getid(fn.winnr('#')))
      command('tabprevious')
      eq(t2_cur_win, api.nvim_tabpage_get_win(t2))

      api.nvim_win_set_config(t2_cur_win, { split = 'left', win = 0 })
      eq(t2_alt_win, api.nvim_tabpage_get_win(t2))
      eq(t1, api.nvim_win_get_tabpage(t2_cur_win))
    end)
    it('set_config cannot change "noautocmd" #36409', function()
      local cfg = { relative = 'editor', row = 1, col = 1, height = 2, width = 2, noautocmd = true }
      local win = api.nvim_open_win(0, false, cfg)
      cfg.height = 10
      eq(true, pcall(api.nvim_win_set_config, win, cfg))
      cfg.noautocmd = false
      eq(
        "'noautocmd' cannot be changed with existing windows",
        pcall_err(api.nvim_win_set_config, win, cfg)
      )
    end)
  end)

  describe('get_config', function()
    it('includes border', function()
      local b = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' }
      local win = api.nvim_open_win(0, true, {
        relative = 'win',
        row = 3,
        col = 3,
        width = 12,
        height = 3,
        border = b,
      })

      local cfg = api.nvim_win_get_config(win)