mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
Add "text search" example
This commit is contained in:
19
text-search-sample/.vscode/launch.json
vendored
Normal file
19
text-search-sample/.vscode/launch.json
vendored
Normal 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
14
text-search-sample/.vscode/tasks.json
vendored
Normal 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
|
||||
}]
|
||||
}
|
||||
1
text-search-sample/README.md
Normal file
1
text-search-sample/README.md
Normal file
@ -0,0 +1 @@
|
||||
# Text Search API Sample
|
||||
2418
text-search-sample/package-lock.json
generated
Normal file
2418
text-search-sample/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
42
text-search-sample/package.json
Normal file
42
text-search-sample/package.json
Normal 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"
|
||||
}
|
||||
}
|
||||
23
text-search-sample/src/extension.ts
Normal file
23
text-search-sample/src/extension.ts
Normal 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');
|
||||
}
|
||||
|
||||
}));
|
||||
}
|
||||
1048
text-search-sample/src/vscode.proposed.d.ts
vendored
Normal file
1048
text-search-sample/src/vscode.proposed.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
15
text-search-sample/tsconfig.json
Normal file
15
text-search-sample/tsconfig.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es5",
|
||||
"outDir": "out",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"sourceMap": true,
|
||||
"rootDir": "src"
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user