diff options
Diffstat (limited to 'packages/core/src/tools/edit.ts')
| -rw-r--r-- | packages/core/src/tools/edit.ts | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/packages/core/src/tools/edit.ts b/packages/core/src/tools/edit.ts index fdabc5b6..cb569f80 100644 --- a/packages/core/src/tools/edit.ts +++ b/packages/core/src/tools/edit.ts @@ -25,6 +25,7 @@ import { ensureCorrectEdit } from '../utils/editCorrector.js'; import { DEFAULT_DIFF_OPTIONS } from './diffOptions.js'; import { openDiff } from '../utils/editor.js'; import { ReadFileTool } from './read-file.js'; +import { EditorType } from '../utils/editor.js'; /** * Parameters for the Edit tool @@ -467,6 +468,19 @@ Expectation for required parameters: } } + async getEditor(outcome: ToolConfirmationOutcome): Promise<EditorType> { + switch (outcome) { + case ToolConfirmationOutcome.ModifyVSCode: + return 'vscode'; + case ToolConfirmationOutcome.ModifyWindsurf: + return 'windsurf'; + case ToolConfirmationOutcome.ModifyCursor: + return 'cursor'; + default: + return 'vim'; + } + } + /** * Creates temp files for the current and proposed file contents and opens a diff tool. * When the diff tool is closed, the tool will check if the file has been modified and provide the updated params. @@ -483,11 +497,9 @@ Expectation for required parameters: this.tempOldDiffPath = oldPath; this.tempNewDiffPath = newPath; - await openDiff( - this.tempOldDiffPath, - this.tempNewDiffPath, - outcome === ToolConfirmationOutcome.ModifyVSCode ? 'vscode' : 'vim', - ); + const editor = await this.getEditor(outcome); + + await openDiff(this.tempOldDiffPath, this.tempNewDiffPath, editor); return await this.getUpdatedParamsIfModified(params, _abortSignal); } |
