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

fix: Potential fix (and potential bugs) #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lua/nvim-drawer/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ function mod.create_drawer(opts)
bufnr = instance.state.windows_and_buffers[winid] or -1
end

-- ... or if we do have a window but don't have a buffer, we use the buffer
-- of the window.
if winid ~= -1 and bufnr == -1 then
bufnr = vim.api.nvim_win_get_buf(winid)
end
Comment on lines +202 to +206
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels "technically correct": when .open is called, and somehow there is a window that belongs to the drawer but it doesn't contain a known buffer, that buffer is used.

The controversial / potential bugs bit is the fact that it happens after the logic for should_reuse_previous_bufnr happens, and that logic very intentionally defaults back to -1.


-- ... and finally if we are trying to make a new window, we just force it
-- to -1 so a buffer will be created.
if opts.mode == 'new' then
Expand Down