Skip to content

Commit 7d20ef6

Browse files
committed
Reading from the commits for autocomplete when enabled
1 parent 4f0d93c commit 7d20ef6

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/lib/questions.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,30 @@ impl ScopeAutocompleter {
117117

118118
Ok(scopes)
119119
}
120+
121+
fn get_config_scopes(&self) -> Vec<String> {
122+
self.config.commit_scopes.keys().cloned().collect()
123+
}
124+
125+
fn get_all_scopes(&self) -> Vec<String> {
126+
let mut scopes = self.get_config_scopes();
127+
let existing_scopes = self.get_existing_scopes().unwrap_or_default();
128+
129+
// Add existing scopes that aren't already in the config scopes
130+
for scope in existing_scopes {
131+
if !scopes.contains(&scope) {
132+
scopes.push(scope);
133+
}
134+
}
135+
136+
scopes
137+
}
120138
}
121139

122140
impl Autocomplete for ScopeAutocompleter {
123141
fn get_suggestions(&mut self, input: &str) -> Result<Vec<String>, CustomUserError> {
124-
let existing_scopes = self.get_existing_scopes().unwrap_or_default();
125-
126-
Ok(existing_scopes
142+
let all_scopes = self.get_all_scopes();
143+
Ok(all_scopes
127144
.iter()
128145
.filter(|s| s.contains(input))
129146
.cloned()

0 commit comments

Comments
 (0)