willothy / flatten.nvim

Open files and command output from wezterm, kitty, and neovim terminals in your current neovim instance
https://luarocks.org/modules/willothy/flatten.nvim
MIT License
473 stars 13 forks source link

feat: smart open should prefer alternative window #83

Closed Bekaboo closed 9 months ago

Bekaboo commented 9 months ago

Currently smart open will pick the FIRST window that is "valid" (a window that is not floating and contains a normal buffer, etc.), which can be unintuitive sometimes.

Suppose I have the following window layout and my cursor is at window B, and in C runs ranger in a terminal:

+-------------------+
|    A    |    B    |
|         |         |
|-------------------|
|    C (terminal)   |
|                   |
+-------------------+

If I switch from B to C using <C-w>j, then open a file from ranger, the current implementation of smart open will open the file in A, but I expect it to be opened in B.

This PR fixes this issue by picking the alternative window (B) if it is valid.