Path: blob/main/extensions/copilot/src/extension/linkify/common/linkifiedText.ts
13399 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 { CancellationToken } from '../../../util/vs/base/common/cancellation';6import { Location, SymbolInformation, Uri } from '../../../vscodeTypes';78export class LinkifyLocationAnchor {9constructor(10public readonly value: Uri | Location,11public readonly title?: string12) { }13}1415export class LinkifySymbolAnchor {16constructor(17public readonly symbolInformation: SymbolInformation,18public readonly resolve?: (token: CancellationToken) => Promise<SymbolInformation>,19) { }20}2122export type LinkifiedPart = string | LinkifyLocationAnchor | LinkifySymbolAnchor;2324export interface LinkifiedText {25readonly parts: readonly LinkifiedPart[];26}2728/**29* Coalesces adjacent string parts into a single string part.30*/31export function coalesceParts(parts: readonly LinkifiedPart[]): LinkifiedPart[] {32const out: LinkifiedPart[] = [];3334for (const part of parts) {35const previous = out.at(-1);36if (typeof part === 'string' && typeof previous === 'string') {37out[out.length - 1] = previous + part;38} else {39out.push(part);40}41}4243return out;44}454647