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 { matchesFuzzy2 } from '../../../base/common/filters.js';
7
>
8
>
/**
9
>
* A leading slash token in a user-message input.
10
>
*/
11
>
export interface ILeadingSlashToken {
12
>
/** The token including the leading slash. */
13
>
readonly token: string;
14
>
/** The typed token text after the slash. */
15
>
readonly typed: string;
16
>
/** The start offset of the token range to replace. */
17
>
readonly rangeStart: number;
18
>
/** The end offset of the token range to replace. */
19
>
readonly rangeEnd: number;
20
>
}
21
>
22
>
/**
23
>
* Extracts the leading `/word` token from the input, where the token is the
24
>
* run of non-whitespace characters starting at offset 0. Returns `undefined`
25
>
* if the input does not start with `/` or the cursor is past the token.
26
>
*/
27
>
export function extractLeadingSlashToken(text: string, offset: number): ILeadingSlashToken | undefined {
28
if (text.length === 0 || text.charCodeAt(0) !== 0x2f /* / */) {
29
return undefined;