Skip to content

Commit

Permalink
#47058 - Search provider running in EH with switch to enable
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed May 9, 2018
1 parent 33a00fd commit 2d08462
Show file tree
Hide file tree
Showing 18 changed files with 2,406 additions and 58 deletions.
4 changes: 4 additions & 0 deletions extensions/search-rg/.vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build/**
src/**
test/**
tsconfig.json
32 changes: 32 additions & 0 deletions extensions/search-rg/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "search-rg",
"description": "%description%",
"displayName": "%displayName%",
"version": "1.0.0",
"icon": "icon.png",
"author": "vscode",
"publisher": "vscode",
"license": "MIT",
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
"enableProposedApi": true,
"engines": {
"vscode": "*"
},
"categories": [],
"dependencies": {
"vscode-extension-telemetry": "0.0.15",
"vscode-nls": "^3.2.1",
"vscode-ripgrep": "^1.0.0"
},
"devDependencies": {
"@types/node": "8.0.33",
"@types/semver": "5.4.0",
"vscode": "^1.1.17"
},
"scripts": {},
"activationEvents": [
"*"
],
"main": "./out/extension",
"contributes": {}
}
4 changes: 4 additions & 0 deletions extensions/search-rg/package.nls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"displayName": "Search",
"description": "Provides search."
}
19 changes: 19 additions & 0 deletions extensions/search-rg/src/extension.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*---------------------------------------------------------------------------------------------
* 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 { RipgrepTextSearchEngine } from './ripgrepTextSearch';

export function activate(): void {
const provider = new RipgrepSearchProvider();
vscode.workspace.registerSearchProvider('file', provider);
}

class RipgrepSearchProvider implements vscode.SearchProvider {
provideTextSearchResults(query: vscode.TextSearchQuery, options: vscode.TextSearchOptions, progress: vscode.Progress<vscode.TextSearchResult>, token: vscode.CancellationToken): Thenable<void> {
const engine = new RipgrepTextSearchEngine();
return engine.provideTextSearchResults(query, options, progress, token);
}
}
34 changes: 34 additions & 0 deletions extensions/search-rg/src/ripgrepHelpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

'use strict';

import * as vscode from 'vscode';

import * as path from 'path';

export function patternsToRgGlobs(patterns: vscode.GlobPattern[]): string[] {
return patterns.map(p => {
if (typeof p === 'string') {
return p;
} else {
// TODO
return p.pattern;
}
});
}

export function fixDriveC(_path: string): string {
const root = path.parse(_path).root;
return root.toLowerCase() === 'c:/' ?
_path.replace(/^c:[/\\]/i, '/') :
_path;
}

function trimTrailingSlash(str: string): string {
return str
.replace(/\/$/, '')
.replace(/\\$/, '');
}

0 comments on commit 2d08462

Please sign in to comment.