Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds --vsplit and --hsplit arguments #2773

Merged
merged 5 commits into from
Jul 1, 2022
Merged

adds --vsplit and --hsplit arguments #2773

merged 5 commits into from
Jul 1, 2022

Conversation

sven-hluchy
Copy link
Contributor

adds the --vsplit and --hsplit features as proposed by #2709.

When multiple files are opened in the editor via the command line, i.e. hx test1.txt test2.txt, the user can use these new arguments to tell the program how these files should be presented.
hx test1.txt test2.txt --vsplit opens both files side-by-side, whereas hx test1.txt test2.txt --hsplit opens them on top of each other.
I also added the new arguments to the completion scripts (hopefully correctly).
If the user passes in both of these options, --vsplit is used as a default.

@EpocSquadron
Copy link
Contributor

What happens if the user opens so many buffers with splits that it can't fit in the editor? Is there a limit? Should there be?

@the-mikedavis
Copy link
Member

There's a practical limit that will lead to a panic with :vsplit (and probably :hsplit too) but I'm not sure if it's based on terminal size: #1083

@EpocSquadron
Copy link
Contributor

That scenario is probably better resolved in a separate PR then.

@sven-hluchy
Copy link
Contributor Author

From what I have been able to gather, the limit of splits you can have does in
fact depend on the size of the window in which helix is opened.

With a terminal of size 2576x1426, the max number of splits the editor can open
without panicking is 17, with a size of 1442x865, the max is only 13.

If one opens more buffers than the editor can "hold", the program panics and
outputs this error message:

thread 'main' panicked at 'attempt to subtract with overflow', helix-view\src\tree.rs:388:50

This line is inside a function called recalculate, which, as the name implies,
is tasked with recalculating the area of the opened buffers.

helix-term/src/args.rs Outdated Show resolved Hide resolved
@sven-hluchy
Copy link
Contributor Author

Little detail, but instead of defaulting to --vsplit, now it instead takes whatever parameter was passed in last, which I think is a better way of handling the case if a user were to use both --vsplit and --hsplit by accident.

Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great 👍

Thanks for updating the completion too 😀

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.

6 participants