stevearc / aerial.nvim

Neovim plugin for a code outline window
MIT License
1.75k stars 86 forks source link

With vertical split windows, when aerial window is opened, the invoking buffer gets squished up (becomes small in width than the irrelevant buffer without corresponding symbols)) #98

Open krishnakumarg1984 opened 2 years ago

krishnakumarg1984 commented 2 years ago

Description Let's say we have two files opened in vertical splits. If we open the symbols outline with any suitable :Aerialxxx command (or keymapping), that window gets squished up (i.e. becomes smaller than the other window which doesn't correspond to the aerial symbols).

The expected behaviour is that the two originally opened windows should retain their width proportions after opening/closing aerial window(s). Examples:

  1. If the two original windows were at 50% widths before opening 1 aerial window, they should remain equal in width after opening it. They should restore to 50% of screen widths after closing the single aerial window.
  2. If the two original windows were at 50% widths before opening 2 aerial windows, they should remain equal in width after opening them. They should still be equal size after closing 1 aerial window. Each should restore to 50% of screen width after closing both the aerial windows.
  3. If one of them was at 40%, and other at 60% width before opening 1 aerial window, they should remain at 2:3 proportion after opening the aerial window, and restore to the original widths after closing the aerial window.
  4. The logic should scale to any number of regular (or aerial) windows.

Preliminary Ideas

  1. Extract the currently open vertical window widths into an array. Ignore any horizontal splits in further width calculations.
  2. Calculate the ratio/proportion of each vertical split
  3. When an aerial window is opened, resize the remaining available screen area based on the above ratio (use the nearest integer multiple/rounding if necessary for the new widths). Of course, each aerial window will respect the max_width, width, and min_width setting tables as usual.
  4. Repeat 3: above when additional aerial windows are used.

System information

Screenshots Before opening aerial window image

After opening aerial window (the buffer from which the :AerialOpen was triggered gets squished up in width). image

stevearc commented 2 years ago

I agree that the windows (especially the active window) getting squished is not ideal. I've pushed up a change that should fix that. This won't produce the exact behavior you're asking for when windows have a manually-set width, but it's far simpler and should cover the common cases.

krishnakumarg1984 commented 2 years ago

Hmm. If you have carefully constructed your window splits layouts (and saved them to a session using a session management plugin), equalising all the other splits after opening an aerial window might not be desirable at all.

This window equalising strategy will also not play well with plugins that provide a golden-ratio layout for the splits.

All in all, while preventing the squishing up is great, it would be respectful of user's custom layouts if the plugin can adhere to the pre-aerial split proportions if it is technically feasible to do so.