refactor(core): share patch write path (#45588)

Share the identical file write, error mapping, and result recording path used by additions and non-moving updates. Keep deletion and moving-update behavior explicit.
This commit is contained in:
Kit Langton
2026-08-27 12:51:58 -04:00
committed by GitHub
parent 95c3c3f962
commit fafcea42e6
+1 -12
View File
@@ -215,17 +215,6 @@ export const Plugin = {
prepared,
(change) =>
Effect.gen(function* () {
if (change.type === "add") {
yield* environment.files
.write(change.target.absolute, new TextEncoder().encode(change.content))
.pipe(Effect.mapError((error) => fail(`Failed to write ${change.target.resource}`, error)))
applied.push({
type: change.type,
resource: change.target.resource,
target: change.target.absolute,
})
return
}
if (change.type === "delete") {
yield* environment.files
.remove(change.target.absolute)
@@ -237,7 +226,7 @@ export const Plugin = {
})
return
}
if (change.moveTarget) {
if (change.type === "update" && change.moveTarget) {
const moveTarget = change.moveTarget
yield* environment.files
.write(moveTarget.absolute, new TextEncoder().encode(change.content))