Skip to content

Commit 36d7bb9

Browse files
committed
refactor(stack): split core/stack/operations.lua by responsibility
Break the 593-line monolith into focused submodules under core/stack/operations/: push, close, focus, history, visibility, cleanup, and query. core/stack.lua remains the public facade and now delegates to each submodule, keeping the external API unchanged while making each operation easier to navigate and test.
1 parent 7f30c09 commit 36d7bb9

9 files changed

Lines changed: 709 additions & 624 deletions

File tree

lua/peekstack/core/stack.lua

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,54 @@
11
local state = require("peekstack.core.stack.state")
2-
local operations = require("peekstack.core.stack.operations")
32
local events = require("peekstack.core.stack.events")
3+
local push_ops = require("peekstack.core.stack.operations.push")
4+
local close_ops = require("peekstack.core.stack.operations.close")
5+
local focus_ops = require("peekstack.core.stack.operations.focus")
6+
local history_ops = require("peekstack.core.stack.operations.history")
7+
local visibility_ops = require("peekstack.core.stack.operations.visibility")
8+
local cleanup_ops = require("peekstack.core.stack.operations.cleanup")
9+
local query_ops = require("peekstack.core.stack.operations.query")
410

511
local M = {}
612

713
M._register_stack_view_win = state.register_stack_view_win
814
M.current_stack = state.ensure_stack
915

10-
M.push = operations.push
11-
M.reflow = operations.reflow
12-
M.list = operations.list
13-
M.current = operations.current
14-
M.close_by_id = operations.close_by_id
15-
M.close = operations.close
16-
M.restore_last = operations.restore_last
17-
M.restore_all = operations.restore_all
18-
M.restore_from_history = operations.restore_from_history
19-
M.history_list = operations.history_list
20-
M.clear_history = operations.clear_history
21-
M.close_current = operations.close_current
22-
M.find_by_winid = operations.find_by_winid
23-
M.find_by_id = operations.find_by_id
24-
M.focus_by_id = operations.focus_by_id
25-
M.reopen_by_id = operations.reopen_by_id
26-
M.focus_next = operations.focus_next
27-
M.focus_prev = operations.focus_prev
28-
M.rename_by_id = operations.rename_by_id
29-
M.toggle_pin_by_id = operations.toggle_pin_by_id
30-
M.touch = operations.touch
31-
M.close_stale = operations.close_stale
32-
M.close_ephemerals = operations.close_ephemerals
33-
M.reflow_all = operations.reflow_all
34-
M.toggle = operations.toggle
35-
M.is_hidden = operations.is_hidden
36-
M.toggle_zoom = operations.toggle_zoom
37-
M.is_zoomed = operations.is_zoomed
38-
M.close_all = operations.close_all
39-
M.focused_id = operations.focused_id
16+
M.push = push_ops.push
17+
18+
M.close = close_ops.close
19+
M.close_by_id = close_ops.close_by_id
20+
M.close_current = close_ops.close_current
21+
M.close_all = close_ops.close_all
22+
23+
M.focus_by_id = focus_ops.focus_by_id
24+
M.focus_next = focus_ops.focus_next
25+
M.focus_prev = focus_ops.focus_prev
26+
M.reopen_by_id = focus_ops.reopen_by_id
27+
28+
M.restore_last = history_ops.restore_last
29+
M.restore_all = history_ops.restore_all
30+
M.restore_from_history = history_ops.restore_from_history
31+
M.history_list = history_ops.history_list
32+
M.clear_history = history_ops.clear_history
33+
34+
M.reflow = visibility_ops.reflow
35+
M.reflow_all = visibility_ops.reflow_all
36+
M.toggle = visibility_ops.toggle
37+
M.is_hidden = visibility_ops.is_hidden
38+
M.toggle_zoom = visibility_ops.toggle_zoom
39+
M.is_zoomed = visibility_ops.is_zoomed
40+
41+
M.close_stale = cleanup_ops.close_stale
42+
M.close_ephemerals = cleanup_ops.close_ephemerals
43+
44+
M.list = query_ops.list
45+
M.current = query_ops.current
46+
M.focused_id = query_ops.focused_id
47+
M.find_by_winid = query_ops.find_by_winid
48+
M.find_by_id = query_ops.find_by_id
49+
M.touch = query_ops.touch
50+
M.rename_by_id = query_ops.rename_by_id
51+
M.toggle_pin_by_id = query_ops.toggle_pin_by_id
4052

4153
M.handle_win_closed = events.handle_win_closed
4254
M.handle_buf_wipeout = events.handle_buf_wipeout

0 commit comments

Comments
 (0)