Skip to content

Commit 0dbcc21

Browse files
committed
Prioritize default code completion config over last selected or first available config
1 parent 0300ecb commit 0dbcc21

1 file changed

Lines changed: 22 additions & 15 deletions

File tree

‎packages/vscode/src/commands/code-completion-commands.ts‎

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,28 @@ const get_code_completion_config = async (
8282
(c) => get_tool_config_id(c) === config_id
8383
) || null
8484
} else if (!show_quick_pick) {
85-
const last_selected_id =
86-
context.workspaceState.get<string>(
87-
LAST_SELECTED_CODE_COMPLETION_CONFIG_ID_STATE_KEY
88-
) ??
89-
context.globalState.get<string>(
90-
LAST_SELECTED_CODE_COMPLETION_CONFIG_ID_STATE_KEY
91-
)
92-
if (last_selected_id) {
93-
selected_config =
94-
code_completions_configs.find(
95-
(c) => get_tool_config_id(c) === last_selected_id
96-
) || null
97-
}
98-
if (!selected_config && code_completions_configs.length > 0) {
99-
selected_config = code_completions_configs[0]
85+
const default_config =
86+
await api_providers_manager.get_default_code_completions_config()
87+
88+
if (default_config) {
89+
selected_config = default_config
90+
} else {
91+
const last_selected_id =
92+
context.workspaceState.get<string>(
93+
LAST_SELECTED_CODE_COMPLETION_CONFIG_ID_STATE_KEY
94+
) ??
95+
context.globalState.get<string>(
96+
LAST_SELECTED_CODE_COMPLETION_CONFIG_ID_STATE_KEY
97+
)
98+
if (last_selected_id) {
99+
selected_config =
100+
code_completions_configs.find(
101+
(c) => get_tool_config_id(c) === last_selected_id
102+
) || null
103+
}
104+
if (!selected_config && code_completions_configs.length > 0) {
105+
selected_config = code_completions_configs[0]
106+
}
100107
}
101108
}
102109

0 commit comments

Comments
 (0)