Skip to content

Commit e1d2bbd

Browse files
committed
Add expand all on tree cell view
1 parent e46bc8b commit e1d2bbd

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

sqlit/core/keymap.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ def _build_action_keys(self) -> list[ActionKeyDef]:
386386
ActionKeyDef("y", "copy_value_view", "value_view"),
387387
ActionKeyDef("t", "toggle_value_view_mode", "value_view"),
388388
ActionKeyDef("z", "collapse_all_json_nodes", "value_view"),
389+
ActionKeyDef("Z", "expand_all_json_nodes", "value_view"),
389390
]
390391

391392

sqlit/domains/results/state/value_view_active.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ class ValueViewTreeModeState(State):
4141

4242
def _setup_actions(self) -> None:
4343
self.allows("collapse_all_json_nodes", key="z", label="Collapse", help="Collapse all nodes")
44+
self.allows("expand_all_json_nodes", key="Z", label="Expand", help="Expand all nodes")
4445
self.allows("toggle_value_view_mode", key="t", label="Syntax View", help="Switch to syntax view")
4546

4647
def get_display_bindings(self, app: InputContext) -> tuple[list[DisplayBinding], list[DisplayBinding]]:
4748
left: list[DisplayBinding] = [
4849
DisplayBinding(key="z", label="Collapse", action="collapse_all_json_nodes"),
50+
DisplayBinding(key="Z", label="Expand", action="expand_all_json_nodes"),
4951
DisplayBinding(key="t", label="Syntax View", action="toggle_value_view_mode"),
5052
]
5153

sqlit/domains/results/ui/mixins/results.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,17 @@ def action_collapse_all_json_nodes(self: ResultsMixinHost) -> None:
307307
except Exception:
308308
pass
309309

310+
def action_expand_all_json_nodes(self: ResultsMixinHost) -> None:
311+
"""Expand all nodes in the JSON tree view."""
312+
from sqlit.shared.ui.widgets import InlineValueView
313+
314+
try:
315+
value_view = self.query_one("#value-view", InlineValueView)
316+
if value_view.is_visible:
317+
value_view.expand_all_nodes()
318+
except Exception:
319+
pass
320+
310321
def action_copy_cell(self: ResultsMixinHost) -> None:
311322
"""Copy the selected cell to clipboard (or internal clipboard)."""
312323
table, _columns, _rows, _stacked = self._get_active_results_context()

sqlit/shared/ui/widgets_value_view.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ def collapse_all_nodes(self) -> None:
8686
except Exception:
8787
pass
8888

89+
def expand_all_nodes(self) -> None:
90+
"""Expand all tree nodes."""
91+
if self._is_json and self._tree_mode:
92+
try:
93+
self.query_one("#json-tree", JSONTreeView).action_expand_all()
94+
except Exception:
95+
pass
96+
8997
def _rebuild(self) -> None:
9098
"""Rebuild the display based on current mode."""
9199
try:

0 commit comments

Comments
 (0)