From 4e31c84e0fe43e0df34b39d70ba279f04240f720 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Mon, 22 Jan 2024 16:21:09 +0100 Subject: [PATCH] make sure textModel0 (and textModekN) has a unique uri (#203015) --- .../inlineChat/browser/inlineChatSessionServiceImpl.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.ts b/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.ts index ab3d899aed6..5e211c6ac6d 100644 --- a/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.ts +++ b/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.ts @@ -22,6 +22,7 @@ import { IEditorWorkerService } from 'vs/editor/common/services/editorWorker'; import { ITextModel, IValidEditOperation } from 'vs/editor/common/model'; import { Schemas } from 'vs/base/common/network'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { generateUuid } from 'vs/base/common/uuid'; type SessionData = { editor: ICodeEditor; @@ -98,6 +99,7 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService { this._logService.trace(`[IE] creating NEW session for ${editor.getId()}, ${provider.debugName}`); const store = new DisposableStore(); + const id = generateUuid(); const targetUri = textModel.uri; let textModelN: ITextModel; @@ -106,7 +108,7 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService { textModelN = store.add(this._modelService.createModel( createTextBufferFactoryFromSnapshot(textModel.createSnapshot()), { languageId: textModel.getLanguageId(), onDidChange: Event.None }, - targetUri.with({ scheme: Schemas.inMemory, query: 'inline-chat-textModelN' }), true + targetUri.with({ scheme: Schemas.inMemory, query: new URLSearchParams({ id, 'inline-chat-textModelN': '' }).toString() }), true )); } else { // AI edits happen in the actual model, keep a reference but make no copy @@ -118,7 +120,7 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService { const textModel0 = store.add(this._modelService.createModel( createTextBufferFactoryFromSnapshot(textModel.createSnapshot()), { languageId: textModel.getLanguageId(), onDidChange: Event.None }, - targetUri.with({ scheme: Schemas.inMemory, query: 'inline-chat-textModel0' }), true + targetUri.with({ scheme: Schemas.inMemory, query: new URLSearchParams({ id, 'inline-chat-textModel0': '' }).toString() }), true )); let wholeRange = options.wholeRange;