on main help sign in
fix:Edit tool error on new file creation due to logical fallthrough (#1566)
commit2e466d841c1355a883565a0b35d750739a760123 authorGustave-241021 <2909789120@qq.com> dateFri 12 Dec 2025, 04:59 (1 year ago) parenta15cf46
1 file changed+3−10
internal/agent/tools/edit.go+3−10
internal/agent/tools/edit.go+3−10
@@ -71,19 +71,12 @@ func NewEditTool(lspClients *csync.Map[string, *lsp.Client], permissions permiss
7171
7272 if params.OldString == "" {
7373 response, err = createNewFile(editCtx, params.FilePath, params.NewString, call)
74− if err != nil {
75− return response, err
76− }
77− }
78−
79− if params.NewString == "" {
74+ } else if params.NewString == "" {
8075 response, err = deleteContent(editCtx, params.FilePath, params.OldString, params.ReplaceAll, call)
81− if err != nil {
82− return response, err
83− }
76+ } else {
77+ response, err = replaceContent(editCtx, params.FilePath, params.OldString, params.NewString, params.ReplaceAll, call)
8478 }
8579
86− response, err = replaceContent(editCtx, params.FilePath, params.OldString, params.NewString, params.ReplaceAll, call)
8780 if err != nil {
8881 return response, err
8982 }