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

Limit the amount of horizontal splits you can do #4642

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

janhrastnik
Copy link
Contributor

Hello,
this PR would address #1084 by setting a limit to the number of horizontal splits you can do.
If there exists a view with a height of 1 (only the status bar is drawn) after hsplit is run, then the newly created view is closed
and we refocus the previous view.

…a height of 1, and will revert the split if they find such a view
@kirawi kirawi added A-helix-term Area: Helix term improvements S-waiting-on-review Status: Awaiting review from a maintainer. C-bug Category: This is a bug labels Nov 9, 2022
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.

I think we will also need this check in split and hsplit_new

// split helper, clear it later
fn split(cx: &mut Context, action: Action) {
let (view, doc) = current!(cx.editor);
let id = doc.id();
let selection = doc.selection(view.id).clone();
let offset = view.offset;
cx.editor.switch(id, action);
// match the selection in the previous view
let (view, doc) = current!(cx.editor);
doc.set_selection(view.id, selection);
// match the view scroll offset (switch doesn't handle this fully
// since the selection is only matched after the split)
view.offset = offset;
}
fn hsplit(cx: &mut Context) {
split(cx, Action::HorizontalSplit);
}
fn hsplit_new(cx: &mut Context) {
cx.editor.new_file(Action::HorizontalSplit);
}
(for repeated splitting by <C-w><C-s>)

@janhrastnik
Copy link
Contributor Author

I didn't include the check in split in commands.rs since vsplit also calls that and I seperated the check into its own function. I hope that's all good.

the-mikedavis
the-mikedavis previously approved these changes Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants