Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/chat/browser/actions/chatClear.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { ServicesAccessor } from '../../../../../platform/instantiation/common/instantiation.js';
7
import { IChatEditorOptions } from '../chatEditor.js';
8
import { ChatEditorInput } from '../chatEditorInput.js';
9
import { IEditorService } from '../../../../services/editor/common/editorService.js';
10
11
export async function clearChatEditor(accessor: ServicesAccessor, chatEditorInput?: ChatEditorInput): Promise<void> {
12
const editorService = accessor.get(IEditorService);
13
14
if (!chatEditorInput) {
15
const editorInput = editorService.activeEditor;
16
chatEditorInput = editorInput instanceof ChatEditorInput ? editorInput : undefined;
17
}
18
19
if (chatEditorInput instanceof ChatEditorInput) {
20
// A chat editor can only be open in one group
21
const identifier = editorService.findEditors(chatEditorInput.resource)[0];
22
await editorService.replaceEditors([{
23
editor: chatEditorInput,
24
replacement: { resource: ChatEditorInput.getNewEditorUri(), options: { pinned: true } satisfies IChatEditorOptions }
25
}], identifier.groupId);
26
}
27
}
28
29