Skip to content

Commit 1725b0d

Browse files
authored
fix: codeBlock version & make sure block file opened (#4474)
1 parent d6ddd66 commit 1725b0d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/ai-native/src/browser/mcp/base-apply.service.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ export abstract class BaseApplyService extends WithEventBus {
247247
originalCode: originalModelRef.instance.getText(),
248248
};
249249
if (uriCodeBlocks?.length) {
250-
newBlock.version = uriCodeBlocks.length;
250+
newBlock.version = uriCodeBlocks.length + 1;
251251
for (const block of uriCodeBlocks) {
252252
// 如果连续的上一个同文件apply结果存在LintError,则iterationCount++
253253
if (block.relativePath === relativePath && block.applyResult?.diagnosticInfos?.length) {
@@ -480,7 +480,7 @@ export abstract class BaseApplyService extends WithEventBus {
480480
}
481481
}
482482

483-
processAll(type: 'accept' | 'reject', uri?: URI): void {
483+
async processAll(type: 'accept' | 'reject', uri?: URI): Promise<void> {
484484
const codeBlocks = uri
485485
? this.getUriCodeBlocks(uri)?.filter((block) => block.status === 'pending')
486486
: this.getSessionCodeBlocks().filter((block) => block.status === 'pending');
@@ -498,6 +498,13 @@ export abstract class BaseApplyService extends WithEventBus {
498498
acc.push(cur);
499499
return acc;
500500
}, [] as string[]);
501+
const openedEditor = this.editorService.getAllOpenedUris();
502+
const unopenedUris = relativePaths
503+
.filter((relativePath) => !openedEditor.some((editor) => editor.codeUri.fsPath.endsWith(relativePath)))
504+
.map((relativePath) => URI.file(path.join(this.appConfig.workspaceDir, relativePath)));
505+
if (unopenedUris.length) {
506+
await this.editorService.openUris(unopenedUris);
507+
}
501508
relativePaths.forEach((relativePath) => {
502509
this.doProcess(type, relativePath);
503510
});

0 commit comments

Comments
 (0)