<commit_before>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';
import * as pathUtils from 'path';

const FILE_LINE_REGEX = /^(\S.*):$/;
const RESULT_LINE_REGEX = /^(\s+)(\d+):(\s+)(.*)$/;

let cachedLastParse: { version: number, parse: ParsedSearchResults } | undefined;

export function activate() {

	vscode.languages.registerDefinitionProvider({ language: 'search-result' }, {
		provideDefinition(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): vscode.DefinitionLink[] {
			const lineResult = parseSearchResults(document, token)[position.line];
			if (!lineResult) { return []; }
			if (lineResult.type === 'file') {
				return lineResult.allLocations.length > 1 ? lineResult.allLocations : [lineResult.location];
			}

			return [lineResult.location];
		}
	});

	vscode.languages.registerDocumentLinkProvider({ language: 'search-result' }, {
		async provideDocumentLinks(document: vscode.TextDocument, token: vscode.CancellationToken): Promise<vscode.DocumentLink[]> {
			return parseSearchResults(document, token)
				.filter(({ type }) => type === 'file')
				.map(({ location }) => ({ range: location.originSelectionRange!, target: location.targetUri }));
		}
	});

	vscode.window.onDidChangeActiveTextEditor(e => {
		if (e?.document.languageId === 'search-result') {<commit_msg>Remove multi-match peek UX.<commit_after>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';
import * as pathUtils from 'path';

const FILE_LINE_REGEX = /^(\S.*):$/;
const RESULT_LINE_REGEX = /^(\s+)(\d+):(\s+)(.*)$/;

let cachedLastParse: { version: number, parse: ParsedSearchResults } | undefined;

export function activate() {

	vscode.languages.registerDefinitionProvider({ language: 'search-result' }, {
		provideDefinition(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): vscode.DefinitionLink[] {
			const lineResult = parseSearchResults(document, token)[position.line];
			if (!lineResult) { return []; }
			if (lineResult.type === 'file') {
				// TODO: The multi-match peek UX isnt very smooth.
				// return lineResult.allLocations.length > 1 ? lineResult.allLocations : [lineResult.location];
				return [];
			}

			return [lineResult.location];
		}
	});

	vscode.languages.registerDocumentLinkProvider({ language: 'search-result' }, {
		async provideDocumentLinks(document: vscode.TextDocument, token: vscode.CancellationToken): Promise<vscode.DocumentLink[]> {
			return parseSearchResults(document, token)
				.filter(({ type }) => type === 'file')
				.map(({ location }) => ({ range: location.originSelectionRange!, target: location.targetUri }));
		}
	});

	vscode.window.onDidChangeActiveTextEditor(e => {
		if (e?.document.languageId === 'search-result') {
{'fraction_non_alphanumeric': 0.24291970802919707, 'fraction_numerical': 0.0005839416058394161, 'mean_word_length': 2.8322147651006713, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5818950', 'n_tokens_mistral': 997, 'n_tokens_neox': 930, 'n_words': 214}