( originalParams: ToolParams, modifyContext: ModifyContext<ToolParams>, editorType: EditorType, _abortSignal: AbortSignal, onEditorClose: () => void, )
| 139 | * and returns the updated tool parameters and the diff after the user has modified the proposed content. |
| 140 | */ |
| 141 | export async function modifyWithEditor<ToolParams>( |
| 142 | originalParams: ToolParams, |
| 143 | modifyContext: ModifyContext<ToolParams>, |
| 144 | editorType: EditorType, |
| 145 | _abortSignal: AbortSignal, |
| 146 | onEditorClose: () => void, |
| 147 | ): Promise<ModifyResult<ToolParams>> { |
| 148 | const currentContent = await modifyContext.getCurrentContent(originalParams); |
| 149 | const proposedContent = |
| 150 | await modifyContext.getProposedContent(originalParams); |
| 151 | |
| 152 | const { oldPath, newPath } = createTempFilesForModify( |
| 153 | currentContent, |
| 154 | proposedContent, |
| 155 | modifyContext.getFilePath(originalParams), |
| 156 | ); |
| 157 | |
| 158 | try { |
| 159 | await openDiff(oldPath, newPath, editorType, onEditorClose); |
| 160 | const result = getUpdatedParams( |
| 161 | oldPath, |
| 162 | newPath, |
| 163 | originalParams, |
| 164 | modifyContext, |
| 165 | ); |
| 166 | |
| 167 | return result; |
| 168 | } finally { |
| 169 | deleteTempFiles(oldPath, newPath); |
| 170 | } |
| 171 | } |
no test coverage detected