Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/inlineEdits/common/nesTriggerHint.ts
13399 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
export enum NesTriggerReason {
7
SelectionChange = 'selectionChange',
8
ActiveDocumentSwitch = 'activeDocumentSwitch',
9
}
10
11
interface NesChangeHintPayload {
12
readonly uuid: string;
13
readonly reason: NesTriggerReason;
14
}
15
16
export interface NesChangeHint {
17
readonly data: NesChangeHintPayload;
18
}
19
20
export namespace NesChangeHint {
21
export function is(obj: unknown): obj is NesChangeHint {
22
if (typeof obj !== 'object' || obj === null) {
23
return false;
24
}
25
const maybeChangeHint = obj as NesChangeHint;
26
return (
27
typeof maybeChangeHint.data === 'object' &&
28
maybeChangeHint.data !== null &&
29
typeof (maybeChangeHint.data as NesChangeHintPayload).uuid === 'string' &&
30
Object.values(NesTriggerReason).includes((maybeChangeHint.data as NesChangeHintPayload).reason)
31
);
32
}
33
}
34
35
36