From 273965ef0b043de82256d48e19c0a3b69d4068a0 Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Thu, 17 Sep 2026 11:03:42 +0200 Subject: [PATCH] Vendor ephemeral_tabs (2.1.8-6) VSCode-style preview tabs: files opened from the treeview with a single click open in a preview tab (titled "~ name ~") that is reused for the next file opened and becomes a permanent tab as soon as it is edited, double-clicked or dragged. Verified against the running editor: single-click opens preview, opening another file replaces it, editing promotes it to a permanent tab. Pinned to lite-xl-plugins @ 31eef29 (see debian/extra/README.source). --- debian/changelog | 10 ++++ debian/extra/README.source | 3 +- debian/extra/plugins/ephemeral_tabs.lua | 77 +++++++++++++++++++++++++ debian/install | 1 + 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 debian/extra/plugins/ephemeral_tabs.lua diff --git a/debian/changelog b/debian/changelog index e7553df..5feb73d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +lite-xl (2.1.8-6) stonking; urgency=medium + + * Vendor ephemeral_tabs (lite-xl-plugins @ 31eef29): files opened from the + treeview with a single click open in a preview tab (titled "~ name ~") + that is reused for the next file and becomes a permanent tab as soon as + it is edited, double-clicked or dragged - matching VSCode's preview + editor behavior. Disable with config.plugins.ephemeral_tabs = false. + + -- Valentin Haudiquet Thu, 17 Sep 2026 10:45:00 +0200 + lite-xl (2.1.8-5) stonking; urgency=medium * Vendor gitpanel 0.3.0 (own plugin, lite-xl-gitpanel @ 0731a63): a git diff --git a/debian/extra/README.source b/debian/extra/README.source index d3db312..ea613cb 100644 --- a/debian/extra/README.source +++ b/debian/extra/README.source @@ -1,7 +1,8 @@ Vendored from upstream, pinned by commit: - lite-xl-plugins https://github.com/lite-xl/lite-xl-plugins @ 31eef29 (master, 2026-09) - plugins/: gitstatus, gitopen, fontconfig, open_ext, select_colorscheme, + plugins/: ephemeral_tabs (VSCode-style preview tabs), gitstatus, gitopen, + fontconfig, open_ext, select_colorscheme, smoothcaret, nerdicons, language_* (all 104; none overlap the ones bundled in the core data/ directory) - lite-xl-gitpanel (own plugin, source tree lite-xl-gitpanel) @ 0731a63 (main, 2026-09) diff --git a/debian/extra/plugins/ephemeral_tabs.lua b/debian/extra/plugins/ephemeral_tabs.lua new file mode 100644 index 0000000..f61c493 --- /dev/null +++ b/debian/extra/plugins/ephemeral_tabs.lua @@ -0,0 +1,77 @@ +-- mod-version:3 +local core = require "core" +local command = require "core.command" +local RootView = require "core.rootview" +local DocView = require "core.docview" +local Doc = require "core.doc" +local TreeView = require "plugins.treeview" + +local RootView_open_doc = RootView.open_doc +function RootView:open_doc(doc) + local docview = RootView_open_doc(self, doc) + -- The absence of the ephemeral flag means that before this moment in this + -- node this document was not exists + if docview.ephemeral == nil then + local node = self:get_active_node_default() + -- We assume that ephemeral tab is always the last one + -- But user can drag and drop tabs so full check is needed + for i, v in ipairs(node.views) do + if v.ephemeral then + node:close_view(self.root_node, v) + end + end + docview.ephemeral = true + end + return docview +end + +local Doc_get_name = DocView.get_name +function DocView:get_name() + return self.doc and self.ephemeral and ("~ " .. Doc_get_name(self) .. " ~") + or Doc_get_name(self) +end + +-- Any change to the document makes the tab normal +local Doc_on_text_change = Doc.on_text_change +function Doc:on_text_change(type) + core.active_view.ephemeral = false + Doc_on_text_change(self, type) +end + +-- Double clicking in the TreeView makes the tab normal +local TreeView_on_mouse_pressed = TreeView.on_mouse_pressed +function TreeView:on_mouse_pressed(button, x, y, clicks) + local result = TreeView_on_mouse_pressed(self, button, x, y, clicks) + if (clicks > 1) and (core.active_view.doc ~= nil) then + core.active_view.ephemeral = false + end + return result +end + +-- Double clicking on a tab makes it normal +local RootView_on_mouse_pressed = RootView.on_mouse_pressed +function RootView:on_mouse_pressed(button, x, y, clicks) + local result = RootView_on_mouse_pressed(self, button, x, y, clicks) + if clicks > 1 then + local node = self.root_node:get_child_overlapping_point(x, y) + local idx = node:get_tab_overlapping_point(x, y) + if idx then + node.views[idx].ephemeral = false + end + end + return result +end + +-- Dragging a tab makes it normal +local RootView_on_mouse_released = RootView.on_mouse_released +function RootView:on_mouse_released(button, x, y, ...) + if self.dragged_node then + if button == "left" then + if self.dragged_node.dragging then + local view = self.dragged_node.node.views[self.dragged_node.idx] + view.ephemeral = false + end + end + end + return RootView_on_mouse_released(self, button, x, y, ...) +end diff --git a/debian/install b/debian/install index 2b36999..e449d39 100644 --- a/debian/install +++ b/debian/install @@ -4,6 +4,7 @@ debian/extra/plugins/lsp usr/share/lite-xl/plugins debian/extra/libraries/widget usr/share/lite-xl/libraries debian/extra/libraries/font_symbols_nerdfont_mono_regular.lua usr/share/lite-xl/libraries/ debian/extra/fonts/SymbolsNerdFontMono-Regular.ttf usr/share/lite-xl/libraries/font_symbols_nerdfont_mono_regular/ +debian/extra/plugins/ephemeral_tabs.lua usr/share/lite-xl/plugins/ debian/extra/plugins/fontconfig.lua usr/share/lite-xl/plugins/ debian/extra/plugins/gitopen.lua usr/share/lite-xl/plugins/ debian/extra/plugins/gitpanel.lua usr/share/lite-xl/plugins/