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

bug: incorrect height of preview (type=main) #468

Closed
3 tasks done
aimuzov opened this issue Jun 2, 2024 · 5 comments · Fixed by #461
Closed
3 tasks done

bug: incorrect height of preview (type=main) #468

aimuzov opened this issue Jun 2, 2024 · 5 comments · Fixed by #461
Labels
bug Something isn't working

Comments

@aimuzov
Copy link

aimuzov commented Jun 2, 2024

Did you check docs and existing issues?

  • I have read all the trouble.nvim docs
  • I have searched the existing issues of trouble.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.10.0

Operating system/version

MacOS 14.5

Describe the bug

There is an bug related to the winbar when calculating the window height. The window must be one line less in height, otherwise it overlaps with the win separator.

Screen.Recording.2024-06-02.at.08.56.43.mov.mp4

If I change the return value of the parent_size function then the problem goes away:

function M:parent_size()
  if self.opts.relative == "editor" or self.opts.relative == "cursor" then
    return { width = vim.o.columns, height = vim.o.lines }
  end

  return { 
		width = vim.api.nvim_win_get_width(self.opts.win), 
		height = vim.api.nvim_win_get_height(self.opts.win) - 1 -- << ???
		-- I don't know how to check that winbar exists in the parent window
	}
end

Fix solves this:

Screen.Recording.2024-06-02.at.09.13.23.mov.mp4

Please tell me how I can find out the correct height required for the preview window?

Steps To Reproduce

  1. Setup winbar.
  2. Open diagnostic (trouble).
  3. Pay attention to the window separator.

Expected Behavior

The window divider should not be overlapped by the preview window.

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/trouble.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
@aimuzov aimuzov added the bug Something isn't working label Jun 2, 2024
@aimuzov
Copy link
Author

aimuzov commented Jun 2, 2024

@b1nhack, can you check it for yourself?

@b1nhack
Copy link

b1nhack commented Jun 2, 2024

I also have an issue with the window separator. When the preview window type is set to 'main' and a winbar is present, the size calculation for the preview window becomes problematic, causing it to overlap the window separator. When the type is 'main,' the preview maybe implemented as a fixed-size floating window, but the calculation for this window ignores the winbar, leading to the issue.

@b1nhack
Copy link

b1nhack commented Jun 2, 2024

There's another issue: when the type is set to 'main', the floating window does not override the default winblend setting. The desired effect is for the preview window to be completely opaque, making it look like it is previewing in the original window.

@aimuzov
Copy link
Author

aimuzov commented Jun 2, 2024

ty :)

@folke
Copy link
Owner

folke commented Jun 2, 2024

@b1nhack just also changed the default winblend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants