fix window sizing issue when running :RegisterEdit from a very small window#11
Conversation
|
Great, for the common case (just opening another register, from a register split) appears like it just works! Stress testing it with something like: what happens when I have many multiline registers open and starting to run out of space: ^ here I repeatedly open a multiline Do you think it's worth doing anything about these edge cases? |
|
Code looks ok to me |
|
In the commit messages, could you put the |
ddc2f50 to
c533d65
Compare
|
I see what you mean about the one buffer growing and the other sometimes being 0 lines tall. I never tested with multiline registers, whoops. It's hard to tell exactly why that happens, but yeah I guess when you run out of space things get tricky. Here's a video just to demonstrate the issue. Screen.Recording.2025-05-09.093959.mp4And here's a video of a 1-line register, which actually also has the same problem given enough lack of space. Screen.Recording.2025-05-09.094527.mp4Not sure if I'll be able to think of any way to handle it, especially since it's hard to reason what the proper behavior should actually be. One way around this kind of problem would be to change the plugin behavior such that instead of opening a horizontal split window, it pops up some other kind of temporary buffer, like a floating window. But I don't think that's needed. I guess the ideal behavior is maybe the register edit window doesn't change ANY window sizes at all, and just consumes the bottom N lines of the current window. But then what if there's not enough room? Again, it's hard to determine the desired behavior. |
|
Hmm, yeah, the behavior earlier in the multi-arg PR where it would eventually hit a "not enough room" builtin error was nice, is there any way we could force that to happen? (in this PR it no longer happens neither with too many args or when space runs out one-at-a-time) There's still one edge case to consider though: imagine you had 100 paragraphs of Lorem Ipsum in a clipboard-style register. Wouldn't want to disallow viewing or editing it so it should have some fairly large maximum size and be a scrollable split. But this further makes the running-out-of-space case more complicated 😄 Yes, needs some thought. Definitely prioritize the simple and realistic usage cases. |
This still happens. The very end of both the videos above shows it happening.
I think we could solve this with just - local window_height = #buf_lines
+ local window_height = math.max(#buf_lines, MAX_BUFFER_LINES)and set |
|
Yeah, max buffer lines sounds like a great idea |
related to tuurep#11
|
Ok great. Another idea I had was what if the register changes to be much shorter? Should we shrink it? For instance, the buffer contains 10 lines and then later it updates (after #12 is in place) to just 1 line. Should we resize the window to be 1 line tall? |
|
Yeah, if it was simple/doable, would like this the most:
But I would anticipate a lot of edge cases so let's see how realistic it is 😄 |
|
Ok, good idea. However, I think maybe it's out of the scope of this PR since this was just for opening buffers. Maybe #12 can include the bit about resizing the windows automatically since that's the one about the autocommands. |
|
Yeah, outside of this PR sounds good |
|
In that case, do you think this one is ready to merge? Maybe you could summarize any outstanding problem in a new GitHub issue and we can merge this one. |
|
Yeah most likely, I'll make sure tomorrow |
|
Yes, this PR is nice and simple, we can merge it I wanted to understand why this is specifically + -- make sure the old window is big enough to split
+ vim.api.nvim_win_set_height(old_window_id, old_window_height + 2)Testing it with So yes definitely seems right I'll open 2 related issues now: |
|
Thank you for this! |

Closes #1
In order to preserve the layout of existing windows, it makes sense to turn off
equalalwayswhile messing with the window splits. Afterwards, we can turn it back on if it was on before.In order to make sure there is actually enough room to split the new window, we have to slightly enlarge the previous window first when
equalalwaysis off.TODO list
equalalwaysandnoequalalwaysoptions.