Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set winbar throws not enough space error even when there's space. #19464

Open
shadmansaleh opened this issue Jul 22, 2022 · 6 comments · May be fixed by #25192
Open

Set winbar throws not enough space error even when there's space. #19464

shadmansaleh opened this issue Jul 22, 2022 · 6 comments · May be fixed by #25192
Assignees
Labels
bug issues reporting wrong behavior float floating windows options configuration, settings statusline tabline, winbar, statuscolumn
Milestone

Comments

@shadmansaleh
Copy link
Contributor

shadmansaleh commented Jul 22, 2022

Neovim version (nvim -v)

0.8.0 commit 1f1863e

Vim (not Nvim) behaves the same?

no

Operating system/version

Arch linux

Terminal name/version

Kitty terminal

$TERM environment variable

screen-256color

Installation

build from repo

How to reproduce the issue

Reproduction steps

-- file: minimal_reproduce.lua
local win = vim.api.nvim_get_current_win()
vim.wo[win].winbar = '%f'

local grp = vim.api.nvim_create_augroup('asdf', {clear=true})
vim.api.nvim_create_autocmd('WinEnter', {
  group = grp,
  pattern = '*',
  desc = 'winbar crash?',
  callback = function ()
    vim.wo[win].winbar = '%f'
  end
})

local buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_open_win(buf, true, {
  relative = "win",
  win = win,
  border = 'single',
  col = 1,
  row = 1,
  height = 1,
  width = 40,
})
nvim --clean minimal_reproduce.lua
:lua require('minimal_reproduce')

Things to note

  • A winbar on current win is already set.
  • We are trying to set winbar of previous win while entering the float of height 1 in auto command context.

Expected behavior

No error should be thrown as the original window has enough space in it to draw winbar.

Actual behavior

It throws following error

Error detected while processing WinEnter Autocommands for "*":
Error executing lua callback: ./minimal_reproduce.lua:10: Vim:E36: Not enough room
stack traceback:
        [C]: in function '__newindex'
        ./minimal_reproduce.lua:10: in function <./minimal_reproduce.lua:9>
        [C]: in function 'nvim_open_win'
        ./minimal_reproduce.lua:15: in main chunk
        [C]: in function 'require'
        [string ":lua"]:1: in main chunk

Speculations

It seems nvim is trying to draw winbar on the float even though winbar option in that window is empty . This can actually be seen if you open the float with height 2 the float buffer starts after an empty line.

@famiu any clue ?

@shadmansaleh shadmansaleh added the bug issues reporting wrong behavior label Jul 22, 2022
@zeertzjq zeertzjq added the statusline tabline, winbar, statuscolumn label Jul 22, 2022
@zeertzjq zeertzjq added this to the 0.8 milestone Jul 22, 2022
shadmansaleh added a commit to nvim-lualine/lualine.nvim that referenced this issue Jul 22, 2022
about not having space in floating windows.

This implements a temporary workaround the issue(neovim/neovim#19464)
until the bug in neovim gets fixed.
shadmansaleh added a commit to nvim-lualine/lualine.nvim that referenced this issue Jul 22, 2022
* feat: refresh lualine based on timer.

* fix config test

* fix lag on win change issue

* handle errors in timer callback

* feat: add winbar support

Pull in winbar changes form pr #689 and adapt them
Co-authored-by: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com>

* make winbar disapear when winbar evals empty

* only update stl of curwin with globalstatus

* properly clear win local stl and wbr opts

* add version guards for winbar feature

* only add winbar if height > 1

* fix tests?

* refresh lualine on ModeChanged event

* ignore floating windows for refresh

* properply restore options to previous state

* fix stl not updating in cmd mode + some optimizations

* fix tests on <nvim-0.7

* merge status_dispatch & winbar_dispatch + winbar support for extensions

* fix globalstatus option not live updating

* update docs

* feat: allow disabling winbar and statusline separately

* fix tests

* fix: winbar some times oddly throwing errors

about not having space in floating windows.

This implements a temporary workaround the issue(neovim/neovim#19464)
until the bug in neovim gets fixed.

Co-authored-by: Diego Fujii <android.mxdiego9@gmail.com>
@famiu
Copy link
Member

famiu commented Jul 25, 2022

There isn't enough room on the floating window since it's only a single row and the only row cannot be a winbar, and winbar will not resize float windows by its own volition

@justinmk justinmk removed the bug issues reporting wrong behavior label Jul 25, 2022
@justinmk justinmk closed this as not planned Won't fix, can't repro, duplicate, stale Jul 25, 2022
@zeertzjq zeertzjq removed this from the 0.8 milestone Jul 25, 2022
@zeertzjq zeertzjq reopened this Jul 25, 2022
@zeertzjq zeertzjq added the bug issues reporting wrong behavior label Jul 25, 2022
@zeertzjq zeertzjq added this to the 0.8 milestone Jul 25, 2022
@zeertzjq zeertzjq added the float floating windows label Jul 25, 2022
@zeertzjq
Copy link
Member

zeertzjq commented Jul 25, 2022

When a floating window is created its 'winbar' option is not cleared.

@shadmansaleh
Copy link
Contributor Author

There isn't enough room on the floating window since it's only a single row and the only row cannot be a winbar, and winbar will not resize float windows by its own volition

You're missing the point . The floating window isn't suppose to have a winbar . The winbar option is set as window local option on a different window.

@famiu
Copy link
Member

famiu commented Jul 26, 2022

It seems like this is still intended behavior since floating windows are supposed to act like split windows but just floating, so it's desired for them to inherit all options from the last window.

@shadmansaleh
Copy link
Contributor Author

In that case why doesn't winbar get set if the autocommand isn't there ?

-- file: minimal_reproduce.lua
local win = vim.api.nvim_get_current_win()
vim.wo[win].winbar = '%f'

local buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_open_win(buf, true, {
  relative = "win",
  win = win,
  border = 'single',
  col = 1,
  row = 1,
  height = 1,
  width = 40,
})

This should throw error too right ?

Note floats with height 1 is a lot more common then splits with height 1. It's not very likely you'll hit not enough space error with splits but you'll regularly hit it with floats as a ton of plugins use single height floats (I think lsp & diagnostic code in core does too). And if it's the default behavior then it's impossible handle this error as nvim_open_win will be throwing error about not having enough space even before anything can clear that inherited winbar .

Winbar in floats are already an exception as in they don't render globar winbar option (BTW why was this decision made ?) I think it's better if floats don't inherit winbar option.

shadmansaleh added a commit to nvim-lualine/lualine.nvim that referenced this issue Jul 27, 2022
some of them are caused by neovim/neovim#15300
some are neovim/neovim#19464
and other unknown bugs too

So as workaround don't update statusline in autocmd context immediately
instead defer the refresh to 50ms later in timer context.

fixes #751 #753 #755
@bfredl bfredl modified the milestones: 0.9, 0.8 Aug 18, 2022
@zeertzjq
Copy link
Member

zeertzjq commented Sep 18, 2022

A workaround is to switch to the floating window later, after it's buffer is set, by passing false as the second argument of nvim_open_win and using nvim_set_current_win later instead:

-- file: minimal_reproduce.lua
local win = vim.api.nvim_get_current_win()
vim.wo[win].winbar = '%f'

local grp = vim.api.nvim_create_augroup('asdf', {clear=true})
vim.api.nvim_create_autocmd('WinEnter', {
  group = grp,
  pattern = '*',
  desc = 'winbar crash?',
  callback = function ()
    vim.wo[win].winbar = '%f'
  end
})

local buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_set_current_win(vim.api.nvim_open_win(buf, false, {
  relative = "win",
  win = win,
  border = 'single',
  col = 1,
  row = 1,
  height = 1,
  width = 40,
}))

This workaround works for WinEnter, BufEnter, BufWinEnter, WinLeave etc., but not BufLeave.

@zeertzjq zeertzjq added has:workaround issue is not fixed but can be circumvented until then and removed has:workaround issue is not fixed but can be circumvented until then labels Sep 18, 2022
@bfredl bfredl removed this from the 0.8 milestone Sep 30, 2022
@bfredl bfredl added this to the 0.9 milestone Sep 30, 2022
@bfredl bfredl modified the milestones: 0.9, 0.10 Apr 7, 2023
@zeertzjq zeertzjq added the options configuration, settings label Apr 18, 2023
vhyrro added a commit to nvim-neorg/neorg that referenced this issue Apr 27, 2023
…ot enough room" errors

This is a temporary hacky fix that should be removed with neovim/neovim#19464
folke pushed a commit to folke/noice.nvim that referenced this issue Jun 26, 2023
Due to the neovim upstream issue (neovim/neovim#19464),
creating a float window will always inherit the winbar from the parent window.
As such, the window height need to be >=2 to prevent "E36: Not enough room" error.
willothy pushed a commit to willothy/noice.nvim that referenced this issue Aug 19, 2023
Due to the neovim upstream issue (neovim/neovim#19464),
creating a float window will always inherit the winbar from the parent window.
As such, the window height need to be >=2 to prevent "E36: Not enough room" error.
@dundargoc dundargoc modified the milestones: 0.10, backlog Mar 30, 2024
craigmac pushed a commit to craigmac/lualine.nvim that referenced this issue May 15, 2024
)

* feat: refresh lualine based on timer.

* fix config test

* fix lag on win change issue

* handle errors in timer callback

* feat: add winbar support

Pull in winbar changes form pr nvim-lualine#689 and adapt them
Co-authored-by: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com>

* make winbar disapear when winbar evals empty

* only update stl of curwin with globalstatus

* properly clear win local stl and wbr opts

* add version guards for winbar feature

* only add winbar if height > 1

* fix tests?

* refresh lualine on ModeChanged event

* ignore floating windows for refresh

* properply restore options to previous state

* fix stl not updating in cmd mode + some optimizations

* fix tests on <nvim-0.7

* merge status_dispatch & winbar_dispatch + winbar support for extensions

* fix globalstatus option not live updating

* update docs

* feat: allow disabling winbar and statusline separately

* fix tests

* fix: winbar some times oddly throwing errors

about not having space in floating windows.

This implements a temporary workaround the issue(neovim/neovim#19464)
until the bug in neovim gets fixed.

Co-authored-by: Diego Fujii <android.mxdiego9@gmail.com>
craigmac pushed a commit to craigmac/lualine.nvim that referenced this issue May 15, 2024
some of them are caused by neovim/neovim#15300
some are neovim/neovim#19464
and other unknown bugs too

So as workaround don't update statusline in autocmd context immediately
instead defer the refresh to 50ms later in timer context.

fixes nvim-lualine#751 nvim-lualine#753 nvim-lualine#755
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior float floating windows options configuration, settings statusline tabline, winbar, statuscolumn
Projects
None yet
6 participants