Changesets · Branches · Tags · Compare
| Changeset | fdb30f09b9b2d2e5030f6fb1279419424cef6e88a2f84b922ad4569f04753e55 |
|---|---|
| Author | Qian <71264725+QianKuang8@users.noreply.github.com> · 2025-08-16 04:39 +08:00 |
| Committer | GitHub <noreply@github.com> · 2025-08-15 13:39 -07:00 |
| Parents | 935a14819b15 |
1 file changed
modified extensions/vscode/src/apply/ApplyManager.ts +28 −20
| @@ -50,37 +50,45 @@ | ||
| 50 | 50 | toolCallId, |
| 51 | 51 | }); |
| 52 | 52 | |
| 53 | - const hasExistingDocument = !!activeTextEditor.document.getText().trim(); | |
| 53 | + try { | |
| 54 | + const hasExistingDocument = !!activeTextEditor.document.getText().trim(); | |
| 54 | 55 | |
| 55 | - if (hasExistingDocument) { | |
| 56 | - // Currently `isSearchAndReplace` will always provide a full file rewrite | |
| 57 | - // as the contents of `text`, so we can just instantly apply | |
| 58 | - if (isSearchAndReplace) { | |
| 59 | - const diffLinesGenerator = generateLines( | |
| 60 | - myersDiff(activeTextEditor.document.getText(), text), | |
| 61 | - ); | |
| 56 | + if (hasExistingDocument) { | |
| 57 | + // Currently `isSearchAndReplace` will always provide a full file rewrite | |
| 58 | + // as the contents of `text`, so we can just instantly apply | |
| 59 | + if (isSearchAndReplace) { | |
| 60 | + const diffLinesGenerator = generateLines( | |
| 61 | + myersDiff(activeTextEditor.document.getText(), text), | |
| 62 | + ); | |
| 62 | 63 | |
| 63 | - await this.verticalDiffManager.streamDiffLines( | |
| 64 | - diffLinesGenerator, | |
| 65 | - true, | |
| 66 | - streamId, | |
| 67 | - toolCallId, | |
| 68 | - ); | |
| 64 | + await this.verticalDiffManager.streamDiffLines( | |
| 65 | + diffLinesGenerator, | |
| 66 | + true, | |
| 67 | + streamId, | |
| 68 | + toolCallId, | |
| 69 | + ); | |
| 70 | + } else { | |
| 71 | + await this.handleExistingDocument( | |
| 72 | + activeTextEditor, | |
| 73 | + text, | |
| 74 | + streamId, | |
| 75 | + toolCallId, | |
| 76 | + ); | |
| 77 | + } | |
| 69 | 78 | } else { |
| 70 | - await this.handleExistingDocument( | |
| 79 | + await this.handleEmptyDocument( | |
| 71 | 80 | activeTextEditor, |
| 72 | 81 | text, |
| 73 | 82 | streamId, |
| 74 | 83 | toolCallId, |
| 75 | 84 | ); |
| 76 | 85 | } |
| 77 | - } else { | |
| 78 | - await this.handleEmptyDocument( | |
| 79 | - activeTextEditor, | |
| 80 | - text, | |
| 86 | + } finally { | |
| 87 | + await this.webviewProtocol.request("updateApplyState", { | |
| 81 | 88 | streamId, |
| 89 | + status: "closed", | |
| 82 | 90 | toolCallId, |
| 83 | - ); | |
| 91 | + }); | |
| 84 | 92 | } |
| 85 | 93 | } |
| 86 | 94 |