Path: blob/main/src/vs/workbench/contrib/chat/browser/actions/chatClear.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { ServicesAccessor } from '../../../../../platform/instantiation/common/instantiation.js';6import { IChatEditorOptions } from '../chatEditor.js';7import { ChatEditorInput } from '../chatEditorInput.js';8import { IEditorService } from '../../../../services/editor/common/editorService.js';910export async function clearChatEditor(accessor: ServicesAccessor, chatEditorInput?: ChatEditorInput): Promise<void> {11const editorService = accessor.get(IEditorService);1213if (!chatEditorInput) {14const editorInput = editorService.activeEditor;15chatEditorInput = editorInput instanceof ChatEditorInput ? editorInput : undefined;16}1718if (chatEditorInput instanceof ChatEditorInput) {19// A chat editor can only be open in one group20const identifier = editorService.findEditors(chatEditorInput.resource)[0];21await editorService.replaceEditors([{22editor: chatEditorInput,23replacement: { resource: ChatEditorInput.getNewEditorUri(), options: { pinned: true } satisfies IChatEditorOptions }24}], identifier.groupId);25}26}272829