Skip to content

Commit f1bf37a

Browse files
authored
fix(context): unify path validation by merging global and profile paths (#1146)
1 parent e0f65f3 commit f1bf37a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

crates/q_cli/src/cli/chat/context.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,8 @@ impl ContextManager {
110110
/// # Returns
111111
/// A Result indicating success or an error
112112
pub async fn add_paths(&mut self, paths: Vec<String>, global: bool, force: bool) -> Result<()> {
113-
// Get reference to the appropriate config
114-
let config = if global {
115-
&mut self.global_config
116-
} else {
117-
&mut self.profile_config
118-
};
113+
let mut all_paths = self.global_config.paths.clone();
114+
all_paths.append(&mut self.profile_config.paths.clone());
119115

120116
// Validate paths exist before adding them
121117
if !force {
@@ -134,10 +130,14 @@ impl ContextManager {
134130

135131
// Add each path, checking for duplicates
136132
for path in paths {
137-
if config.paths.contains(&path) {
138-
return Err(eyre!("Path '{}' already exists in the context", path));
133+
if all_paths.contains(&path) {
134+
return Err(eyre!("Rule '{}' already exists.", path));
135+
}
136+
if global {
137+
self.global_config.paths.push(path);
138+
} else {
139+
self.profile_config.paths.push(path);
139140
}
140-
config.paths.push(path);
141141
}
142142

143143
// Save the updated configuration

0 commit comments

Comments
 (0)