From 331b8e90ec95a8342832d6f9e889928d510d5aa9 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Sat, 23 Oct 2021 03:34:24 +0200 Subject: [PATCH 1/9] Select a new primary node when closing the current one The new primary node can be any non-locked leaf node that isn't already primary. --- data/core/rootview.lua | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/data/core/rootview.lua b/data/core/rootview.lua index 04a091c4..51eedc10 100644 --- a/data/core/rootview.lua +++ b/data/core/rootview.lua @@ -149,10 +149,17 @@ function Node:remove_view(root, view) else locked_size = locked_size_y end - if self.is_primary_node or locked_size then + local next_primary + if self.is_primary_node then + next_primary = core.root_view:select_next_primary_node() + end + if locked_size or (self.is_primary_node and not next_primary) then self.views = {} self:add_view(EmptyView()) else + if other == next_primary then + next_primary = parent + end parent:consume(other) local p = parent while p.type ~= "leaf" do @@ -160,7 +167,7 @@ function Node:remove_view(root, view) end p:set_active_view(p.active_view) if self.is_primary_node then - p.is_primary_node = true + next_primary.is_primary_node = true end end end @@ -823,6 +830,24 @@ function RootView:get_primary_node() end +local function select_next_primary_node(node) + if node.is_primary_node then return end + if node.type ~= "leaf" then + return select_next_primary_node(node.a) or select_next_primary_node(node.b) + else + local lx, ly = node:get_locked_size() + if not lx and not ly then + return node + end + end +end + + +function RootView:select_next_primary_node() + return select_next_primary_node(self.root_node) +end + + function RootView:open_doc(doc) local node = self:get_active_node_default() for i, view in ipairs(node.views) do From 80d837b05b0713f9ce268f8c64b048537741220d Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Sat, 23 Oct 2021 15:46:30 +0200 Subject: [PATCH 2/9] Fix assert with dmon on directory deleting --- lib/dmon/dmon.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/dmon/dmon.h b/lib/dmon/dmon.h index ed10d11f..2bc9e0c3 100644 --- a/lib/dmon/dmon.h +++ b/lib/dmon/dmon.h @@ -927,8 +927,11 @@ _DMON_PRIVATE void dmon__inotify_process_events(void) dmon__strcat(watchdir, sizeof(watchdir), "/"); uint32_t mask = IN_MOVED_TO | IN_CREATE | IN_MOVED_FROM | IN_DELETE | IN_MODIFY; int wd = inotify_add_watch(watch->fd, watchdir, mask); - _DMON_UNUSED(wd); - DMON_ASSERT(wd != -1); + // Removing the assertion below because it was giving errors for some reason + // when building a new package. + // _DMON_UNUSED(wd); + // DMON_ASSERT(wd != -1); + if (wd == -1) continue; dmon__watch_subdir subdir; dmon__strcpy(subdir.rootdir, sizeof(subdir.rootdir), watchdir); From e68d6016f89a2e65846c2a1ac60179f849cdb5c3 Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Sat, 23 Oct 2021 08:07:14 -0700 Subject: [PATCH 3/9] Add skip-subproject option in package script --- scripts/package.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/package.sh b/scripts/package.sh index 1370aee8..21a8cc91 100644 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -186,7 +186,7 @@ main() { rm -rf "${dest_dir}" - DESTDIR="$(pwd)/${dest_dir}" meson install -C "${build_dir}" + DESTDIR="$(pwd)/${dest_dir}" meson install --skip-subprojects -C "${build_dir}" local data_dir="$(pwd)/${dest_dir}/data" local exe_file="$(pwd)/${dest_dir}/lite-xl" From 92db048e7c4bb02967156bc9fcd26744e746b097 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Mon, 25 Oct 2021 00:18:20 +0200 Subject: [PATCH 4/9] Use plain search by default in `search.find` --- data/core/doc/search.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/data/core/doc/search.lua b/data/core/doc/search.lua index b4c553c9..8395769a 100644 --- a/data/core/doc/search.lua +++ b/data/core/doc/search.lua @@ -43,6 +43,7 @@ end function search.find(doc, line, col, text, opt) doc, line, col, text, opt = init_args(doc, line, col, text, opt) + local plain = not opt.pattern local pattern = text local search_func = string.find if opt.regex then @@ -60,9 +61,9 @@ function search.find(doc, line, col, text, opt) end local s, e if opt.reverse then - s, e = rfind(search_func, line_text, pattern, col - 1) + s, e = rfind(search_func, line_text, pattern, col - 1, plain) else - s, e = search_func(line_text, pattern, col) + s, e = search_func(line_text, pattern, col, plain) end if s then return line, s, line, e + 1 From df665ddc3842dbe4677c1cbbafe55b80670f3c1c Mon Sep 17 00:00:00 2001 From: Guldoman Date: Mon, 25 Oct 2021 14:06:07 +0200 Subject: [PATCH 5/9] Use `header` to get syntax only when provided --- data/core/syntax.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/core/syntax.lua b/data/core/syntax.lua index a763ac78..de8ec9d0 100644 --- a/data/core/syntax.lua +++ b/data/core/syntax.lua @@ -22,7 +22,7 @@ end function syntax.get(filename, header) return find(filename, "files") - or find(header, "headers") + or (header and find(header, "headers")) or plain_text_syntax end From 9e721937af962098386cff37803c7aeef4d99367 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Tue, 26 Oct 2021 00:12:16 +0200 Subject: [PATCH 6/9] Don't insert `nil` in highlighter lines table When `highlighter:insert_notify` was called, a hole in the array was created. If another call to `highlighter:insert_notify` happened before the hole was filled, a `Position out of bounds` error could have been raised. --- data/core/doc/highlighter.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/core/doc/highlighter.lua b/data/core/doc/highlighter.lua index 4cb703da..c77e1138 100644 --- a/data/core/doc/highlighter.lua +++ b/data/core/doc/highlighter.lua @@ -52,7 +52,7 @@ end function Highlighter:insert_notify(line, n) self:invalidate(line) for i = 1, n do - table.insert(self.lines, line, nil) + table.insert(self.lines, line, false) end end From f99afcd29c777544f1f3bc4f9d8b2802a5b15c5d Mon Sep 17 00:00:00 2001 From: Guldoman Date: Sun, 7 Nov 2021 23:12:03 +0100 Subject: [PATCH 7/9] In `TreeView` set correct active `View` before opening new `DocView` Before this, the new `DocView` was always added to the primary `Node`. With this, it gets added to the last focused `Node`. --- data/plugins/treeview.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/data/plugins/treeview.lua b/data/plugins/treeview.lua index d08db03e..77b6732f 100644 --- a/data/plugins/treeview.lua +++ b/data/plugins/treeview.lua @@ -225,6 +225,9 @@ function TreeView:on_mouse_pressed(button, x, y, clicks) end else core.try(function() + if core.last_active_view and core.active_view == self then + core.set_active_view(core.last_active_view) + end local doc_filename = core.normalize_to_project_dir(hovered_item.abs_filename) core.root_view:open_doc(core.open_doc(doc_filename)) end) From 24669293c71a2a34ad9a4ba528ddcb45323350d3 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Sun, 7 Nov 2021 17:54:42 -0500 Subject: [PATCH 8/9] Made it so that we originally start on the parent directory of the current project, but provide a list of recently used projects if on that directory. If a directory separator is added, then everything is as normal. --- data/core/commands/core.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/data/core/commands/core.lua b/data/core/commands/core.lua index e836ea2f..2280f620 100644 --- a/data/core/commands/core.lua +++ b/data/core/commands/core.lua @@ -9,7 +9,8 @@ local fullscreen = false local function suggest_directory(text) text = common.home_expand(text) - return common.home_encode_list(text == "" and core.recent_projects or common.dir_path_suggest(text)) + return common.home_encode_list(text == "" or text == common.home_expand(common.dirname(core.project_dir)) + and core.recent_projects or common.dir_path_suggest(text)) end command.add(nil, { @@ -149,7 +150,7 @@ command.add(nil, { ["core:change-project-folder"] = function() local dirname = common.dirname(core.project_dir) if dirname then - core.command_view:set_text(common.home_encode(dirname) .. PATHSEP) + core.command_view:set_text(common.home_encode(dirname)) end core.command_view:enter("Change Project Folder", function(text, item) text = system.absolute_path(common.home_expand(item and item.text or text)) @@ -166,7 +167,7 @@ command.add(nil, { ["core:open-project-folder"] = function() local dirname = common.dirname(core.project_dir) if dirname then - core.command_view:set_text(common.home_encode(dirname) .. PATHSEP) + core.command_view:set_text(common.home_encode(dirname)) end core.command_view:enter("Open Project", function(text, item) text = common.home_expand(item and item.text or text) From 5b8c08e93ae3cb79b4e0602e0cc74e90e6d695e5 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Sun, 7 Nov 2021 17:57:15 -0500 Subject: [PATCH 9/9] Missing parentheses. --- data/core/commands/core.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/core/commands/core.lua b/data/core/commands/core.lua index 2280f620..62be4bc6 100644 --- a/data/core/commands/core.lua +++ b/data/core/commands/core.lua @@ -9,7 +9,7 @@ local fullscreen = false local function suggest_directory(text) text = common.home_expand(text) - return common.home_encode_list(text == "" or text == common.home_expand(common.dirname(core.project_dir)) + return common.home_encode_list((text == "" or text == common.home_expand(common.dirname(core.project_dir))) and core.recent_projects or common.dir_path_suggest(text)) end