focus.nvim icon indicating copy to clipboard operation
focus.nvim copied to clipboard

Support horizontal splits for focus_max_or_equal

Open jerryjrchen opened this issue 1 year ago • 3 comments

At present it only checks for window width, which works for vertical splits. However, horizontal splits will not properly maximise since they will always have the max width, so attempts to focus_max_or_equal will always lead to focus_equalise.

Minimal repro setup:

-- minimal_init.lua
vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
    spec = {
        { 'nvim-focus/focus.nvim', version = false, lazy = false, opts = true }
    },
})

Repro:

  1. nvim -u minimal_init.lua
  2. Open a horizontal split (e.g. :split and :help lua)
  3. Try running :FocusMaxOrEqual, it doesn't toggle the window sizing

https://github.com/user-attachments/assets/259980ed-d9a1-401a-888d-f915811e41f5

https://github.com/user-attachments/assets/fa6eda7c-ebbc-45dd-9a31-b0927bafccf4

jerryjrchen avatar Jul 16 '24 16:07 jerryjrchen

Thank you very much for your contribution.

Could you please add tests for it? Take a look at https://github.com/nvim-focus/focus.nvim/blob/master/tests/test_splits.lua

make test will run the tests.

cryptomilk avatar Jul 17 '24 16:07 cryptomilk

@cryptomilk I'd like to write a test for even vs odd row/col count window sizes, but I'm not super familiar with MiniTest and if there's a way to do that. What do you think about opening a floating window or something with fixed dimensions to do some split testing?

jerryjrchen avatar Jul 18 '24 15:07 jerryjrchen

That's all possible. See the new_set() function in the tests, it calls child.set_size(50, 180) which sets the size of nvim in rows and columns.

cryptomilk avatar Jul 19 '24 07:07 cryptomilk

Ping

cryptomilk avatar Mar 04 '25 18:03 cryptomilk

Superseded by #178 which includes a test.

cryptomilk avatar Nov 14 '25 16:11 cryptomilk