Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/prompts/node/panel/terminalSelection.tsx
13405 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 { BasePromptElementProps, PromptElement, PromptPiece, PromptSizing, UserMessage } from '@vscode/prompt-tsx';
7
import { ITerminalService } from '../../../../platform/terminal/common/terminalService';
8
9
export interface ProjectLabelsProps extends BasePromptElementProps { }
10
11
export class TerminalSelection extends PromptElement<ProjectLabelsProps, string> {
12
constructor(
13
props: ProjectLabelsProps,
14
@ITerminalService private readonly _terminalService: ITerminalService
15
) {
16
super(props);
17
}
18
19
override async prepare(): Promise<string> {
20
return this._terminalService.terminalSelection;
21
}
22
23
override render(state: string, sizing: PromptSizing): PromptPiece<any, any> | undefined {
24
if (state.trim().length === 0) {
25
return (<>
26
<UserMessage priority={this.props.priority}>
27
The active terminal has no selection.
28
</UserMessage >
29
</>);
30
}
31
32
return (<>
33
<UserMessage priority={this.props.priority}>
34
The active terminal's selection:<br />
35
{state}
36
</UserMessage >
37
</>);
38
}
39
}
40
41