mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 19:44:25 +01:00
release inline chat session for untitled file when it becomes saved (non-dirty) (#203454)
fixes https://github.com/microsoft/vscode/issues/203448
This commit is contained in:
@@ -23,6 +23,7 @@ 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';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
|
||||
type SessionData = {
|
||||
editor: ICodeEditor;
|
||||
@@ -58,6 +59,7 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService {
|
||||
@IEditorWorkerService private readonly _editorWorkerService: IEditorWorkerService,
|
||||
@ILogService private readonly _logService: ILogService,
|
||||
@IInstantiationService private readonly _instaService: IInstantiationService,
|
||||
@ITextFileService private readonly _textFileService: ITextFileService,
|
||||
) { }
|
||||
|
||||
dispose() {
|
||||
@@ -123,6 +125,18 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService {
|
||||
targetUri.with({ scheme: Schemas.inMemory, query: new URLSearchParams({ id, 'inline-chat-textModel0': '' }).toString() }), true
|
||||
));
|
||||
|
||||
// untitled documents are special
|
||||
if (targetUri.scheme === Schemas.untitled) {
|
||||
const untitledTextModel = this._textFileService.untitled.get(targetUri);
|
||||
if (untitledTextModel) {
|
||||
store.add(untitledTextModel.onDidChangeDirty(() => {
|
||||
if (!untitledTextModel.isDirty()) {
|
||||
this.releaseSession(session);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
let wholeRange = options.wholeRange;
|
||||
if (!wholeRange) {
|
||||
wholeRange = rawSession.wholeRange ? Range.lift(rawSession.wholeRange) : editor.getSelection();
|
||||
|
||||
Reference in New Issue
Block a user