Skip to content

Commit fde44db

Browse files
committed
feat: add SlintOptions to WorkspaceSettings and update UI handlers to properly save slint specific settings
1 parent 356e477 commit fde44db

File tree

5 files changed

+67
-6
lines changed

5 files changed

+67
-6
lines changed

src/core/workspace.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ pub struct WorkspaceSettings {
1919
pub dirs_only: bool,
2020
#[serde(flatten)]
2121
pub rust: RustOptions,
22+
#[serde(flatten)]
23+
pub slint: SlintOptions,
2224
}
2325

2426
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)]
@@ -33,6 +35,14 @@ pub struct RustOptions {
3335
pub rust_signatures_only_filter: String,
3436
}
3537

38+
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)]
39+
pub struct SlintOptions {
40+
#[serde(default)]
41+
pub slint_remove_line_comments: bool,
42+
#[serde(default)]
43+
pub slint_remove_block_comments: bool,
44+
}
45+
3646
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3747
pub struct LocalSettings {
3848
#[serde(default)]

src/ui/handlers.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use notify::{RecommendedWatcher, RecursiveMode, Watcher};
1313
use std::sync::mpsc;
1414

1515
use stitch::core::{
16-
Node, Profile, ProfileScope, RustFilterOptions, RustOptions, WorkspaceSettings,
16+
Node, Profile, ProfileScope, RustFilterOptions, RustOptions, SlintOptions, WorkspaceSettings,
1717
apply_rust_filters, apply_slint_filters, clean_remove_regex, collapse_consecutive_blank_lines,
1818
collect_selected_paths, compile_remove_regex_opt, delete_profile, ensure_profiles_dirs,
1919
ensure_workspace_dir, gather_paths_set, is_ancestor_of, is_rust_file_path, is_slint_file_path,
@@ -209,6 +209,9 @@ pub fn on_select_folder(app: &AppWindow, state: &SharedState) {
209209
app.set_rust_remove_doc_comments(ws.rust.rust_remove_doc_comments);
210210
app.set_rust_function_signatures_only(ws.rust.rust_function_signatures_only);
211211
app.set_rust_signatures_only_filter(ws.rust.rust_signatures_only_filter.clone().into());
212+
// Slint settings
213+
app.set_slint_remove_line_comments(ws.slint.slint_remove_line_comments);
214+
app.set_slint_remove_block_comments(ws.slint.slint_remove_block_comments);
212215

213216
state.borrow_mut().workspace_baseline = Some(ws.clone());
214217
} else {
@@ -227,6 +230,10 @@ pub fn on_select_folder(app: &AppWindow, state: &SharedState) {
227230
rust_function_signatures_only: app.get_rust_function_signatures_only(),
228231
rust_signatures_only_filter: app.get_rust_signatures_only_filter().to_string(),
229232
},
233+
slint: SlintOptions {
234+
slint_remove_line_comments: app.get_slint_remove_line_comments(),
235+
slint_remove_block_comments: app.get_slint_remove_block_comments(),
236+
},
230237
};
231238
let _ = save_workspace(&dir, &seed);
232239
state.borrow_mut().workspace_baseline = Some(seed);
@@ -1526,6 +1533,10 @@ fn capture_profile_from_ui(app: &AppWindow, state: &SharedState, name: &str) ->
15261533
rust_function_signatures_only: app.get_rust_function_signatures_only(),
15271534
rust_signatures_only_filter: app.get_rust_signatures_only_filter().to_string(),
15281535
},
1536+
slint: SlintOptions {
1537+
slint_remove_line_comments: app.get_slint_remove_line_comments(),
1538+
slint_remove_block_comments: app.get_slint_remove_block_comments(),
1539+
},
15291540
};
15301541

15311542
// NOTE: Preserve root selection by storing an empty relative path ("")
@@ -1573,6 +1584,8 @@ fn apply_profile_to_ui(app: &AppWindow, state: &SharedState, profile: &Profile)
15731584
.clone()
15741585
.into(),
15751586
);
1587+
app.set_slint_remove_line_comments(profile.settings.slint.slint_remove_line_comments);
1588+
app.set_slint_remove_block_comments(profile.settings.slint.slint_remove_block_comments);
15761589

15771590
app.set_profile_name(profile.name.clone().into());
15781591

@@ -1683,6 +1696,10 @@ pub fn on_save_profile_current(app: &AppWindow, state: &SharedState) {
16831696
rust_function_signatures_only: app.get_rust_function_signatures_only(),
16841697
rust_signatures_only_filter: app.get_rust_signatures_only_filter().to_string(),
16851698
},
1699+
slint: SlintOptions {
1700+
slint_remove_line_comments: app.get_slint_remove_line_comments(),
1701+
slint_remove_block_comments: app.get_slint_remove_block_comments(),
1702+
},
16861703
};
16871704

16881705
let _ = save_workspace(&project_root, &ws);
@@ -1839,6 +1856,8 @@ fn profiles_equal(a: &Profile, b: &Profile) -> bool {
18391856
|| sa.rust.rust_remove_doc_comments != sb.rust.rust_remove_doc_comments
18401857
|| sa.rust.rust_function_signatures_only != sb.rust.rust_function_signatures_only
18411858
|| sa.rust.rust_signatures_only_filter != sb.rust.rust_signatures_only_filter
1859+
|| sa.slint.slint_remove_line_comments != sb.slint.slint_remove_line_comments
1860+
|| sa.slint.slint_remove_block_comments != sb.slint.slint_remove_block_comments
18421861
{
18431862
return false;
18441863
}
@@ -1881,6 +1900,10 @@ fn update_save_button_state(app: &AppWindow, state: &SharedState) {
18811900
rust_function_signatures_only: app.get_rust_function_signatures_only(),
18821901
rust_signatures_only_filter: app.get_rust_signatures_only_filter().to_string(),
18831902
},
1903+
slint: SlintOptions {
1904+
slint_remove_line_comments: app.get_slint_remove_line_comments(),
1905+
slint_remove_block_comments: app.get_slint_remove_block_comments(),
1906+
},
18841907
};
18851908

18861909
let baseline_opt = { state.borrow().workspace_baseline.clone() };
@@ -2043,6 +2066,7 @@ fn workspace_settings_equal(a: &WorkspaceSettings, b: &WorkspaceSettings) -> boo
20432066
&& a.hierarchy_only == b.hierarchy_only
20442067
&& a.dirs_only == b.dirs_only
20452068
&& a.rust == b.rust
2069+
&& a.slint == b.slint
20462070
// Note: we intentionally ignore `current_profile` here for dirtiness comparison
20472071
}
20482072

tests/profile_persistence.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use stitch::core::{
2-
Profile, ProfileScope, ProfileSelection, RustOptions, WorkspaceSettings, delete_profile,
3-
ensure_profiles_dirs, ensure_workspace_dir, list_profiles, load_profile, save_profile,
2+
Profile, ProfileScope, ProfileSelection, RustOptions, SlintOptions, WorkspaceSettings,
3+
delete_profile, ensure_profiles_dirs, ensure_workspace_dir, list_profiles, load_profile,
4+
save_profile,
45
};
56
use tempfile::TempDir;
67

@@ -36,6 +37,10 @@ fn sample_ws() -> WorkspaceSettings {
3637
rust_function_signatures_only: false,
3738
rust_signatures_only_filter: String::new(),
3839
},
40+
slint: SlintOptions {
41+
slint_remove_line_comments: false,
42+
slint_remove_block_comments: false,
43+
},
3944
}
4045
}
4146

tests/workspace_current_profile.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use stitch::core::{
2-
LocalSettings, Profile, ProfileScope, RustOptions, WorkspaceSettings,
2+
LocalSettings, Profile, ProfileScope, RustOptions, SlintOptions, WorkspaceSettings,
33
clear_stale_current_profile, load_local_settings, save_local_settings, save_profile,
44
};
55
use tempfile::TempDir;
@@ -54,6 +54,10 @@ fn no_clear_when_shared_profile_exists() {
5454
rust_function_signatures_only: false,
5555
rust_signatures_only_filter: String::new(),
5656
},
57+
slint: SlintOptions {
58+
slint_remove_line_comments: false,
59+
slint_remove_block_comments: false,
60+
},
5761
},
5862
explicit: vec![],
5963
};
@@ -93,6 +97,10 @@ fn no_clear_when_local_profile_exists() {
9397
rust_function_signatures_only: false,
9498
rust_signatures_only_filter: String::new(),
9599
},
100+
slint: SlintOptions {
101+
slint_remove_line_comments: false,
102+
slint_remove_block_comments: false,
103+
},
96104
},
97105
explicit: vec![],
98106
};

tests/workspace_persistence.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use stitch::core::{
2-
RustOptions, WorkspaceSettings, ensure_workspace_dir, load_workspace, save_workspace,
3-
workspace_dir, workspace_file,
2+
RustOptions, SlintOptions, WorkspaceSettings, ensure_workspace_dir, load_workspace,
3+
save_workspace, workspace_dir, workspace_file,
44
};
55
use tempfile::TempDir;
66

@@ -41,6 +41,10 @@ fn save_then_load_roundtrip_and_overwrite_is_atomic() {
4141
rust_function_signatures_only: false,
4242
rust_signatures_only_filter: String::new(),
4343
},
44+
slint: SlintOptions {
45+
slint_remove_line_comments: true,
46+
slint_remove_block_comments: false,
47+
},
4448
};
4549
save_workspace(root, &s1).expect("save v1");
4650

@@ -68,17 +72,27 @@ fn save_then_load_roundtrip_and_overwrite_is_atomic() {
6872
loaded1.rust.rust_function_signatures_only,
6973
s1.rust.rust_function_signatures_only
7074
);
75+
assert_eq!(
76+
loaded1.slint.slint_remove_line_comments,
77+
s1.slint.slint_remove_line_comments
78+
);
79+
assert_eq!(
80+
loaded1.slint.slint_remove_block_comments,
81+
s1.slint.slint_remove_block_comments
82+
);
7183

7284
let mut s2 = loaded1;
7385
s2.ext_filter = ".rs".into();
7486
s2.hierarchy_only = true;
7587
s2.rust.rust_signatures_only_filter = "src/*,tests/*".into();
88+
s2.slint.slint_remove_block_comments = true;
7689
save_workspace(root, &s2).expect("save v2 overwrite");
7790

7891
let loaded2 = load_workspace(root).expect("load s2");
7992
assert_eq!(loaded2.ext_filter, ".rs");
8093
assert!(loaded2.hierarchy_only);
8194
assert_eq!(loaded2.rust.rust_signatures_only_filter, "src/*,tests/*");
95+
assert!(loaded2.slint.slint_remove_block_comments);
8296

8397
let tmp_path = wf.with_extension("json.tmp");
8498
assert!(

0 commit comments

Comments
 (0)