1
>
/*---------------------------------------------------------------------------------------------
ripgrepSearchUtils.ts
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 { ILogService } from '../../../../platform/log/common/log.js';
7
>
import { SearchRange } from '../common/search.js';
8
>
import * as searchExtTypes from '../common/searchExtTypes.js';
9
>
10
>
export type Maybe<T> = T | null | undefined;
11
>
12
>
export function anchorGlob(glob: string): string {
13
return glob.startsWith('**') || glob.startsWith('/') ? glob : `/${glob}`;
14
}
16
>
export function rangeToSearchRange(range: searchExtTypes.Range): SearchRange {
17
return new SearchRange(range.start.line, range.start.character, range.end.line, range.end.character);
18
}
20
>
export function searchRangeToRange(range: SearchRange): searchExtTypes.Range {
21
return new searchExtTypes.Range(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn);
22
}
24
>
export interface IOutputChannel {
25
>
appendLine(msg: string): void;
26
>
}
27
>
28
>
export class OutputChannel implements IOutputChannel {
29
>
constructor(private prefix: string, @ILogService private readonly logService: ILogService) { }
30
>
31
>
appendLine(msg: string): void {
32
this.logService.debug(`${this.prefix}#search`, msg);
33
}