Elffuss BraidHub

kikocis/continue public

fix: vscode apply error (#7168)

fix: vscode apply
Changesetfdb30f09b9b2d2e5030f6fb1279419424cef6e88a2f84b922ad4569f04753e55
AuthorQian <71264725+QianKuang8@users.noreply.github.com> · 2025-08-16 04:39 +08:00
CommitterGitHub <noreply@github.com> · 2025-08-15 13:39 -07:00
Parents935a14819b15

Browse the files at this changeset

1 file changed

modified extensions/vscode/src/apply/ApplyManager.ts +28 −20
@@ -50,37 +50,45 @@
5050 toolCallId,
5151 });
5252
53- const hasExistingDocument = !!activeTextEditor.document.getText().trim();
53+ try {
54+ const hasExistingDocument = !!activeTextEditor.document.getText().trim();
5455
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+ );
6263
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+ }
6978 } else {
70- await this.handleExistingDocument(
79+ await this.handleEmptyDocument(
7180 activeTextEditor,
7281 text,
7382 streamId,
7483 toolCallId,
7584 );
7685 }
77- } else {
78- await this.handleEmptyDocument(
79- activeTextEditor,
80- text,
86+ } finally {
87+ await this.webviewProtocol.request("updateApplyState", {
8188 streamId,
89+ status: "closed",
8290 toolCallId,
83- );
91+ });
8492 }
8593 }
8694