Skip to content

Commit 697bd6a

Browse files
committed
push fix(?) for str_replace not editing files
1 parent 4ab1968 commit 697bd6a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

backend/src/tools/handlers/tool/str-replace.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,16 @@ export const handleStrReplace = ((params: {
5252
fileProcessingState.promisesByPath[path] = []
5353
}
5454

55-
const latestContentPromise = Promise.all(
56-
fileProcessingState.promisesByPath[path],
57-
).then((results) => {
58-
const previousEdit = results.findLast((r) => 'content' in r)
59-
return previousEdit ? previousEdit.content : requestOptionalFile(ws, path)
60-
})
55+
const previousPromises = fileProcessingState.promisesByPath[path]
56+
const previousEdit = previousPromises[previousPromises.length - 1]
57+
58+
const latestContentPromise = previousEdit
59+
? previousEdit.then((maybeResult) =>
60+
maybeResult && 'content' in maybeResult
61+
? maybeResult.content
62+
: requestOptionalFile(ws, path),
63+
)
64+
: requestOptionalFile(ws, path)
6165

6266
const newPromise = processStrReplace(path, replacements, latestContentPromise)
6367
.catch((error: any) => {

0 commit comments

Comments
 (0)