Skip to content

Commit f1400ca

Browse files
committed
feat(state): split state in smaller slices
1 parent 04f4064 commit f1400ca

15 files changed

Lines changed: 1027 additions & 922 deletions

File tree

lua/opencode/api.lua

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ local function build_toggle_open_context(restore_hidden)
8989
}
9090
end
9191

92-
local focus = config.ui.input.auto_hide and 'input'
93-
or state.last_focused_opencode_window
94-
or 'input'
92+
local focus = config.ui.input.auto_hide and 'input' or state.last_focused_opencode_window or 'input'
9593

9694
return {
9795
focus = focus,
@@ -100,21 +98,20 @@ local function build_toggle_open_context(restore_hidden)
10098
end
10199

102100
M.toggle = Promise.async(function(new_session)
103-
local decision = state.resolve_toggle_decision(
104-
config.ui.persist_state,
105-
state.display_route ~= nil
106-
)
101+
local decision = state.ui.resolve_toggle_decision(config.ui.persist_state, state.display_route ~= nil)
107102
local action = decision.action
108103
local is_new_session = new_session == true
109104

110105
local function open_windows(restore_hidden)
111106
local ctx = build_toggle_open_context(restore_hidden == true)
112-
return core.open({
113-
new_session = is_new_session,
114-
focus = ctx.focus,
115-
start_insert = false,
116-
open_action = ctx.open_action,
117-
}):await()
107+
return core
108+
.open({
109+
new_session = is_new_session,
110+
focus = ctx.focus,
111+
start_insert = false,
112+
open_action = ctx.open_action,
113+
})
114+
:await()
118115
end
119116

120117
local function open_fresh_windows()

lua/opencode/core.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ M.open = Promise.async(function(opts)
104104
if restoring_hidden then
105105
local restored = ui.restore_hidden_windows()
106106
if not restored then
107-
state.clear_hidden_window_state()
107+
state.ui.clear_hidden_window_state()
108108
restoring_hidden = false
109109
state.ui.set_windows(ui.create_windows())
110110
end

0 commit comments

Comments
 (0)