Skip to content

Commit 9032a3a

Browse files
committed
hsplit_limit_check now checks if the view with a height of 1 is a child of the focused view
1 parent 315b9e6 commit 9032a3a

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

helix-term/src/commands/typed.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ pub fn hsplit_limit_check(view_id: ViewId, editor: &mut Editor) {
12751275
if editor
12761276
.tree
12771277
.views()
1278-
.any(|(view, _focused)| view.area.height == 1)
1278+
.any(|(view, _focused)| view.area.height == 1 && editor.tree.is_child(&view.id))
12791279
{
12801280
editor.set_error("Max number of splits reached");
12811281
editor.close(view!(editor).id);

helix-view/src/tree.rs

+14
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,20 @@ impl Tree {
214214
node
215215
}
216216

217+
pub fn is_child(&self, child_id: &ViewId) -> bool {
218+
let focus = self.focus;
219+
let parent = self.nodes[focus].parent;
220+
221+
let container_children: Vec<ViewId> = match &self.nodes[parent] {
222+
Node {
223+
content: Content::Container(container),
224+
..
225+
} => container.children.clone(),
226+
_ => unimplemented!(),
227+
};
228+
container_children.contains(child_id)
229+
}
230+
217231
pub fn remove(&mut self, index: ViewId) {
218232
let mut stack = Vec::new();
219233

0 commit comments

Comments
 (0)