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

not delete buf when hide scrollbar cause it seems not necessary #591

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

tim3nd
Copy link
Contributor

@tim3nd tim3nd commented Dec 16, 2024

Closes #580

There were errors for command-line window cause it's not allowed to delete buffer in command-line window.

At first I want to check if we are in command-line window by checking getcmdwintype(), but seems there is no need to always trying to delete buffer for scrollbar thumb and gutter. Cause blink already can reuse existing buffer for scrollbar thumb and gutter.

see below scrollbar_win:_make_win

function scrollbar_win:_make_win(geometry, hl_group)
  if self.buf == nil or not vim.api.nvim_buf_is_valid(self.buf) then self.buf = vim.api.nvim_create_buf(false, true) end

  local win_config = vim.tbl_deep_extend('force', geometry, {
    style = 'minimal',
    focusable = false,
    noautocmd = true,
  })
  local win = vim.api.nvim_open_win(self.buf, false, win_config)
  vim.api.nvim_set_option_value('winhighlight', 'Normal:' .. hl_group .. ',EndOfBuffer:' .. hl_group, { win = win })
  return win
end

If there are something I missed or got wrong, feel free to modify or give advice :)

@Saghen Saghen merged commit 0046d0c into Saghen:main Dec 16, 2024
@Saghen
Copy link
Owner

Saghen commented Dec 16, 2024

Thanks!

@tim3nd tim3nd deleted the fix-cmdwin_error branch December 16, 2024 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

errors in the command line window
2 participants