@@ -129,8 +129,8 @@ use modalkit::{
129
129
130
130
use modalkit_ratatui:: {
131
131
cmdbar:: CommandBarState ,
132
- screen:: { Screen , ScreenState , TabLayoutDescription } ,
133
- windows:: WindowLayoutDescription ,
132
+ screen:: { Screen , ScreenState , TabbedLayoutDescription } ,
133
+ windows:: { WindowLayoutDescription , WindowLayoutState } ,
134
134
TerminalCursor ,
135
135
TerminalExtOps ,
136
136
Window ,
@@ -176,6 +176,17 @@ fn config_tab_to_desc(
176
176
Ok ( desc)
177
177
}
178
178
179
+ fn restore_layout (
180
+ area : Rect ,
181
+ settings : & ApplicationSettings ,
182
+ store : & mut ProgramStore ,
183
+ ) -> IambResult < FocusList < WindowLayoutState < IambWindow , IambInfo > > > {
184
+ let layout = std:: fs:: read ( & settings. layout_json ) ?;
185
+ let tabs: TabbedLayoutDescription < IambInfo > =
186
+ serde_json:: from_slice ( & layout) . map_err ( IambError :: from) ?;
187
+ tabs. to_layout ( area. into ( ) , store)
188
+ }
189
+
179
190
fn setup_screen (
180
191
settings : ApplicationSettings ,
181
192
store : & mut ProgramStore ,
@@ -186,12 +197,14 @@ fn setup_screen(
186
197
187
198
match settings. layout {
188
199
config:: Layout :: Restore => {
189
- if let Ok ( layout) = std:: fs:: read ( & settings. layout_json ) {
190
- let tabs: TabLayoutDescription < IambInfo > =
191
- serde_json:: from_slice ( & layout) . map_err ( IambError :: from) ?;
192
- let tabs = tabs. to_layout ( area. into ( ) , store) ?;
193
-
194
- return Ok ( ScreenState :: from_list ( tabs, cmd) ) ;
200
+ match restore_layout ( area, & settings, store) {
201
+ Ok ( tabs) => {
202
+ return Ok ( ScreenState :: from_list ( tabs, cmd) ) ;
203
+ } ,
204
+ Err ( e) => {
205
+ // Log the issue with restoring and then continue.
206
+ tracing:: warn!( err = %e, "Failed to restore layout from disk" ) ;
207
+ } ,
195
208
}
196
209
} ,
197
210
config:: Layout :: New => { } ,
@@ -242,7 +255,7 @@ struct Application {
242
255
focused : bool ,
243
256
244
257
/// The tab layout before the last executed [TabAction].
245
- last_layout : Option < TabLayoutDescription < IambInfo > > ,
258
+ last_layout : Option < TabbedLayoutDescription < IambInfo > > ,
246
259
247
260
/// Whether we need to do a full redraw (e.g., after running a subprocess).
248
261
dirty : bool ,
@@ -479,7 +492,7 @@ impl Application {
479
492
None
480
493
} ,
481
494
Action :: Command ( act) => {
482
- let acts = store. application . cmds . command ( & act, & ctx) ?;
495
+ let acts = store. application . cmds . command ( & act, & ctx, & mut store . registers ) ?;
483
496
self . action_prepend ( acts) ;
484
497
485
498
None
0 commit comments