From f9131447c5fbacecd82e9e6e0620cf26ba918959 Mon Sep 17 00:00:00 2001 From: "bobo.yang" Date: Thu, 4 Jul 2024 21:45:00 +0800 Subject: [PATCH] feat: Add autoedit flag for automatic code editing - Introduce autoedit parameter in diffApply function - Implement conditional logic for code application method - Use applyEditCodeWithDiff when autoedit is true --- src/ide_services/endpoints/unofficial.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ide_services/endpoints/unofficial.ts b/src/ide_services/endpoints/unofficial.ts index 25a921e..3bf29a9 100644 --- a/src/ide_services/endpoints/unofficial.ts +++ b/src/ide_services/endpoints/unofficial.ts @@ -1,11 +1,15 @@ import * as vscode from "vscode"; -import { applyCodeWithDiff } from "../../handler/diffHandler"; +import { applyCodeWithDiff, applyEditCodeWithDiff } from "../../handler/diffHandler"; import { getSymbolDefines } from "../../context/contextRefDefs"; export namespace UnofficialEndpoints { - export async function diffApply(filepath: string, content: string) { - applyCodeWithDiff({ fileName: filepath, content: content }, undefined); + export async function diffApply(filepath: string, content: string, autoedit: boolean = false) { + if (autoedit) { + applyEditCodeWithDiff({ fileName: filepath, content: content }, undefined) + } else { + applyCodeWithDiff({ fileName: filepath, content: content }, undefined); + } return true; }