Skip to content

Conversation

@jerryjrchen
Copy link

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
before.mov
after.mov

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.
@jerryjrchen jerryjrchen changed the title Check window width and height for focus_max_or_equal Support horizontal splits for focus_max_or_equal Jul 16, 2024
@cryptomilk
Copy link
Collaborator

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.

@jerryjrchen
Copy link
Author

@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?

@cryptomilk
Copy link
Collaborator

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
Copy link
Collaborator

Ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants