Add "text search" example

This commit is contained in:
Rob Lourens
2018-07-11 19:36:23 -07:00
parent f06607de44
commit d77781882e
8 changed files with 3580 additions and 0 deletions

19
text-search-sample/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,19 @@
// A launch configuration that compiles the extension and then opens it inside a new window
{
"version": "0.1.0",
"configurations": [{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}"
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/out/src/**/*.js"
],
"preLaunchTask": "npm:watch"
}]
}

14
text-search-sample/.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,14 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [{
"identifier": "npm:watch",
"type": "npm",
"script": "watch",
"problemMatcher": [
"$tsc-watch"
],
"isBackground": true
}]
}

View File

@ -0,0 +1 @@
# Text Search API Sample

2418
text-search-sample/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,42 @@
{
"name": "text-search-sample",
"displayName": "Text Search API Sample",
"version": "0.0.1",
"publisher": "roblourens",
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/vscode-extension-samples"
},
"bugs": {
"url": "https://github.com/Microsoft/vscode-extension-samples/issues"
},
"engines": {
"vscode": "^1.25.0"
},
"categories": [
"Other"
],
"activationEvents": [
"onCommand:textsearch.doSearch"
],
"contributes": {
"commands": [
{
"command": "textsearch.doSearch",
"title": "Text Search"
}
]
},
"main": "./out/extension",
"scripts": {
"vscode:prepublish": "tsc -p ./",
"watch": "tsc -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install",
"tslint": "tslint -c tslint.json src/extension.ts"
},
"devDependencies": {
"typescript": "^2.1.4",
"vscode": "^1.1.17",
"@types/node": "^6.0.40"
}
}

View File

@ -0,0 +1,23 @@
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
'use strict';
import * as vscode from 'vscode';
export function activate(context: vscode.ExtensionContext) {
const outputChannel = vscode.window.createOutputChannel('Text Search');
context.subscriptions.push(vscode.commands.registerCommand('textsearch.doSearch', async () => {
const result = await vscode.window.showInputBox();
if (result) {
await vscode.workspace.findTextInFiles({ pattern: result }, { }, result => {
outputChannel.appendLine(`${result.uri.fsPath}(${result.range.start.line}, ${result.range.start.character}): ${result.preview.text}`);
});
outputChannel.appendLine('\n');
}
}));
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,15 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"outDir": "out",
"lib": [
"es6"
],
"sourceMap": true,
"rootDir": "src"
},
"exclude": [
"node_modules"
]
}