Skip to content

Commit

Permalink
still support prompt overrides even when preset disables a completion…
Browse files Browse the repository at this point in the history
… parameter
  • Loading branch information
nvms committed Dec 5, 2023
1 parent 15b28c7 commit 253362c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
20 changes: 10 additions & 10 deletions extension/dist/extension.umd.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions extension/src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ export async function createPrompt(prompt: PromptDefinition & { promptId: string
const editor = vscode.window.activeTextEditor;
const readable = getHumanReadableLanguageName(languageid(editor), extension(editor));
const selection = getSelectionInfo(editor);
const activeModeCompletionParams = getActiveModeActivePresetKeyValue("completionParams") as Preset["completionParams"];
const completionParams = Object.fromEntries(
Object.entries(
getActiveModeActivePresetKeyValue("completionParams") as Preset["completionParams"]
)
Object.entries(activeModeCompletionParams)
.filter(([_, value]) => value != null)
) as unknown as Preset["completionParams"];

Expand Down Expand Up @@ -60,7 +59,9 @@ export async function createPrompt(prompt: PromptDefinition & { promptId: string
const paramName = matchGroups[1];
const paramValue = matchGroups[2];

if (Object.hasOwnProperty.call(completionParams, paramName)) {
// Check against activeModeCompletionParams, because this particular param may have been stripped
// at the Preset level (see assignment to `completionParams`), but we still want the prompt to be able to override this value.
if (Object.hasOwnProperty.call(activeModeCompletionParams, paramName)) {
const numberRegex = /^[0-9]+(\.[0-9]+)?$/;
completionParams[paramName] = numberRegex.test(paramValue) ? Number(paramValue) : paramValue;
}
Expand Down

0 comments on commit 253362c

Please sign in to comment.