From 5a699289243dbf2c59a171bbcebb48946d461565 Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Tue, 14 Sep 2021 12:20:58 +0200 Subject: [PATCH] More accurate logic for node's remove view method Provide an fix like: https://github.com/lite-xl/lite-xl/pull/526 but use instead the is_primary_node property and the context property. We align the logic to the one used in the close_all_views method. The approach using get_locked_size was the old approach using by rxi's lite but it should no longer be used to determine if a node if part of the application UI or part of the document's view. --- data/core/rootview.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/data/core/rootview.lua b/data/core/rootview.lua index 9d017268..067f4c2a 100644 --- a/data/core/rootview.lua +++ b/data/core/rootview.lua @@ -128,6 +128,18 @@ function Node:split(dir, view, locked, resizable) return self.b end + +function Node:is_application() + if self.type == "leaf" then + for i = 1, #self.views do + if self.views[i].context == "application" then return true end + end + else + return self.a:is_application() or self.b:is_application() + end +end + + function Node:remove_view(root, view) if #self.views > 1 then local idx = self:get_view_idx(view) @@ -142,7 +154,7 @@ function Node:remove_view(root, view) local parent = self:get_parent_node(root) local is_a = (parent.a == self) local other = parent[is_a and "b" or "a"] - if other:get_locked_size() then + if self.is_primary_node and other:is_application() then self.views = {} self:add_view(EmptyView()) else