-
Notifications
You must be signed in to change notification settings - Fork 4
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
Ready to make pull request #8
Conversation
Hi! I got this working with neo-tree's Considering these neo-tree events:
I implemented this working solution: ...
event_handlers = {
-- See https://github.com/kwkarlwang/bufresize.nvim/pull/8
{
event = "neo_tree_window_before_open",
handler = function()
require("bufresize").block_register()
end,
},
{
event = "neo_tree_window_after_open",
handler = function()
require("bufresize").resize_open()
end,
},
{
event = "neo_tree_window_before_close",
handler = function()
require("bufresize").block_register()
end,
},
{
event = "neo_tree_window_after_close",
handler = function()
require("bufresize").resize_close()
end,
},
},
... Here's the before and after in that order: |
Hi @serranomorante, glad to see you got it working! Let me explain why So what
Hope this help! |
Thank you so much 😭!! That make things more clear. |
This pull request brings two new functionality,
resize_open
andresize_close
.Problem
The problems I would like to solve is the following.
Normally, if you close window D in the below configuration, the height of window D goes to A and C.
This, at least to me, is strange as I would expect the the height and to be evenly distributed as between B and C
The same goes for opening a new window. For example, if you open toggleterm in vertical direction (windows D in the below figure), the initial windows will go out of proportion.
I expected the width of A and B/C to have the same width as their width proportion was the same before toggling the new windows.
I first notice this phenomena when using toggleterm as shown below.
without_bufresize.mov
Solution
Initially, I was planning to make a new extension to solve this problem. However, I found out that it shares a lot of codebase with
bufresize.nvim
, thus I am adding this functionality in this plugin.The two new functions are
resize_open
andresize_close
. Below is the configuration to solve the problem above.resize_open
: find the newly opened window that is in the current state but not in the registered state, adjust the proportion of registered windows accordingly, then apply resize to the registered windows. Should be use withblock_register
to prevent race conditionresize_close
: find the newly closed window that is not in the registered state but not in the current state, adjust the proportion of registered windows accordingly, then apply resize to the registered windows. Should be use withblock_register
to prevent race conditionA complete list of functions are listed in the README.
With this setup, below is the new behavior.
with_bufresize.mov