From 0dc21cbb821f60698feaddad425d5ea067320cf4 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Sat, 4 Apr 2026 23:21:03 -0500 Subject: [PATCH] refactor: remove split_pane_manager plugin and harden view handling - Delete deprecated split_pane_manager command plugin and all related commands - Introduce new split_pane command structure (untracked replacement) - Add guard in code_minimap to handle missing active view - Prevent language detection for non-file buffers in command_helpers This cleans up legacy split pane logic and improves stability for edge cases. --- .../__init__.py | 0 .../__main__.py | 0 .../close_split_view.py | 15 ++++++++++++++- .../create_split_view.py | 19 +++++++++++++++---- .../focus_left_sibling.py | 0 .../focus_right_sibling.py | 0 .../manifest.json | 2 +- .../move_to_left_sibling.py | 0 .../move_to_right_sibling.py | 0 .../plugin.py | 0 plugins/code/ui/code_minimap/plugin.py | 1 + .../code/command_system/command_helpers.py | 5 ++++- 12 files changed, 35 insertions(+), 7 deletions(-) rename plugins/code/commands/{split_pane_manager => split_pane}/__init__.py (100%) rename plugins/code/commands/{split_pane_manager => split_pane}/__main__.py (100%) rename plugins/code/commands/{split_pane_manager => split_pane}/close_split_view.py (79%) rename plugins/code/commands/{split_pane_manager => split_pane}/create_split_view.py (78%) rename plugins/code/commands/{split_pane_manager => split_pane}/focus_left_sibling.py (100%) rename plugins/code/commands/{split_pane_manager => split_pane}/focus_right_sibling.py (100%) rename plugins/code/commands/{split_pane_manager => split_pane}/manifest.json (73%) rename plugins/code/commands/{split_pane_manager => split_pane}/move_to_left_sibling.py (100%) rename plugins/code/commands/{split_pane_manager => split_pane}/move_to_right_sibling.py (100%) rename plugins/code/commands/{split_pane_manager => split_pane}/plugin.py (100%) diff --git a/plugins/code/commands/split_pane_manager/__init__.py b/plugins/code/commands/split_pane/__init__.py similarity index 100% rename from plugins/code/commands/split_pane_manager/__init__.py rename to plugins/code/commands/split_pane/__init__.py diff --git a/plugins/code/commands/split_pane_manager/__main__.py b/plugins/code/commands/split_pane/__main__.py similarity index 100% rename from plugins/code/commands/split_pane_manager/__main__.py rename to plugins/code/commands/split_pane/__main__.py diff --git a/plugins/code/commands/split_pane_manager/close_split_view.py b/plugins/code/commands/split_pane/close_split_view.py similarity index 79% rename from plugins/code/commands/split_pane_manager/close_split_view.py rename to plugins/code/commands/split_pane/close_split_view.py index 2034fa2..a683788 100644 --- a/plugins/code/commands/split_pane_manager/close_split_view.py +++ b/plugins/code/commands/split_pane/close_split_view.py @@ -16,6 +16,19 @@ from libs.event_factory import Event_Factory, Code_Event_Types emit_to: callable = None +def get_source_view(widget): + if isinstance(widget, GtkSource.View): + return widget + + if isinstance(widget, Gtk.ScrolledWindow): + return widget.get_child() + + if isinstance(widget, Gtk.Paned): + return get_source_view(widget.get_child1()) + + return None + + def execute( source_view, char_str, @@ -39,7 +52,7 @@ def execute( remaining = source_view1 closing_view = source_view - remaining_view = remaining.get_child() + remaining_view = get_source_view(remaining) left = closing_view.sibling_left right = closing_view.sibling_right diff --git a/plugins/code/commands/split_pane_manager/create_split_view.py b/plugins/code/commands/split_pane/create_split_view.py similarity index 78% rename from plugins/code/commands/split_pane_manager/create_split_view.py rename to plugins/code/commands/split_pane/create_split_view.py index 2321550..c781ef0 100644 --- a/plugins/code/commands/split_pane_manager/create_split_view.py +++ b/plugins/code/commands/split_pane/create_split_view.py @@ -54,13 +54,24 @@ def execute( pane.pack2( scrolled_win2, True, True ) container.add(pane) - pane.show_all() + def _show(pane, alloc, is_vertical: bool): + if is_vertical: + pane.set_position(alloc.width / 2) + else: + pane.set_position(alloc.height / 2) + + pane.disconnect(pane.show_id) is_control, is_shift, is_alt = modkeys_states - if is_control and is_shift: + alloc = container.get_allocation() + if char_str == "|": + pane.show_id = pane.connect("show", _show, alloc, True) pane.set_orientation(Gtk.Orientation.VERTICAL) - elif is_control: + elif char_str == "\\": + pane.show_id = pane.connect("show", _show, alloc, False) pane.set_orientation(Gtk.Orientation.HORIZONTAL) - source_view2.grab_focus() + pane.show_all() + source_view2.command.exec("new_file") + source_view2.grab_focus() diff --git a/plugins/code/commands/split_pane_manager/focus_left_sibling.py b/plugins/code/commands/split_pane/focus_left_sibling.py similarity index 100% rename from plugins/code/commands/split_pane_manager/focus_left_sibling.py rename to plugins/code/commands/split_pane/focus_left_sibling.py diff --git a/plugins/code/commands/split_pane_manager/focus_right_sibling.py b/plugins/code/commands/split_pane/focus_right_sibling.py similarity index 100% rename from plugins/code/commands/split_pane_manager/focus_right_sibling.py rename to plugins/code/commands/split_pane/focus_right_sibling.py diff --git a/plugins/code/commands/split_pane_manager/manifest.json b/plugins/code/commands/split_pane/manifest.json similarity index 73% rename from plugins/code/commands/split_pane_manager/manifest.json rename to plugins/code/commands/split_pane/manifest.json index 0c34d9c..03ce4c1 100644 --- a/plugins/code/commands/split_pane_manager/manifest.json +++ b/plugins/code/commands/split_pane/manifest.json @@ -1,5 +1,5 @@ { - "name": "Split Pane Manager", + "name": "Split Pane", "author": "ITDominator", "version": "0.0.1", "support": "", diff --git a/plugins/code/commands/split_pane_manager/move_to_left_sibling.py b/plugins/code/commands/split_pane/move_to_left_sibling.py similarity index 100% rename from plugins/code/commands/split_pane_manager/move_to_left_sibling.py rename to plugins/code/commands/split_pane/move_to_left_sibling.py diff --git a/plugins/code/commands/split_pane_manager/move_to_right_sibling.py b/plugins/code/commands/split_pane/move_to_right_sibling.py similarity index 100% rename from plugins/code/commands/split_pane_manager/move_to_right_sibling.py rename to plugins/code/commands/split_pane/move_to_right_sibling.py diff --git a/plugins/code/commands/split_pane_manager/plugin.py b/plugins/code/commands/split_pane/plugin.py similarity index 100% rename from plugins/code/commands/split_pane_manager/plugin.py rename to plugins/code/commands/split_pane/plugin.py diff --git a/plugins/code/ui/code_minimap/plugin.py b/plugins/code/ui/code_minimap/plugin.py index 5c110ef..7b2c462 100644 --- a/plugins/code/ui/code_minimap/plugin.py +++ b/plugins/code/ui/code_minimap/plugin.py @@ -30,6 +30,7 @@ class Plugin(PluginCode): event = Event_Factory.create_event("get_active_view") self.emit_to("source_views", event) + if not event.response: return code_minimap.set_smini_view(event.response) def unload(self): diff --git a/src/core/widgets/code/command_system/command_helpers.py b/src/core/widgets/code/command_system/command_helpers.py index 33669c9..a43ef1e 100644 --- a/src/core/widgets/code/command_system/command_helpers.py +++ b/src/core/widgets/code/command_system/command_helpers.py @@ -8,7 +8,10 @@ from gi.repository import GtkSource def set_language_and_style(view, file): - language = view.language_manager.guess_language(file.fname, None) + language = None + if not file.fname == "buffer": + language = view.language_manager.guess_language(file.fname, None) + file.buffer.set_language(language) file.buffer.set_style_scheme(view.syntax_theme)