Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/util/common/test/annotatedSrc.ts
13401 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 function deannotateSrc(annotatedSrc: string): {
7
deannotatedSrc: string;
8
annotatedRange: {
9
startIndex: number;
10
endIndex: number;
11
};
12
} {
13
const startIndex = annotatedSrc.indexOf('<<');
14
if (startIndex === -1) {
15
throw new Error('No << found in the annotated source');
16
}
17
const endIndex = annotatedSrc.indexOf('>>') - 2;
18
if (endIndex === -3 /* because `-1-2` */) {
19
throw new Error('No >> found in the annotated source');
20
}
21
return {
22
deannotatedSrc: annotatedSrc.replace('<<', '').replace('>>', ''),
23
annotatedRange: {
24
startIndex,
25
endIndex,
26
},
27
};
28
}
29
30