Path: blob/main/extensions/copilot/src/util/common/test/annotatedSrc.ts
13401 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*--------------------------------------------------------------------------------------------*/45export function deannotateSrc(annotatedSrc: string): {6deannotatedSrc: string;7annotatedRange: {8startIndex: number;9endIndex: number;10};11} {12const startIndex = annotatedSrc.indexOf('<<');13if (startIndex === -1) {14throw new Error('No << found in the annotated source');15}16const endIndex = annotatedSrc.indexOf('>>') - 2;17if (endIndex === -3 /* because `-1-2` */) {18throw new Error('No >> found in the annotated source');19}20return {21deannotatedSrc: annotatedSrc.replace('<<', '').replace('>>', ''),22annotatedRange: {23startIndex,24endIndex,25},26};27}282930