Skip to content

Commit

Permalink
Fix commands
Browse files Browse the repository at this point in the history
  • Loading branch information
ShawnLin013 committed Sep 16, 2020
1 parent 48f3872 commit 3e76c16
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 24 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

Quickly search file name over all files.

## Features
1. Search File Name
2. Search File Name (Match Case)
3. Search File Name (Match Whole Word)
4. Search File Name (Match Case and Whole Word)

## Usage

1. Right click on the file
Expand Down
25 changes: 16 additions & 9 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,28 @@ const vscode = require('vscode');
const ncp = require("copy-paste");
const path = require("path");

function activate(context) {
let disposable = vscode.commands.registerCommand('extension.searchFileName', function (fileUri) {
function addCommand(context, command, matchCase, matchWholeWord) {
let searchFileName = vscode.commands.registerCommand(command, function (fileUri) {
if (fileUri != undefined) {
var name = path.basename(fileUri.fsPath);
ncp.copy(name, function() {
vscode.commands.executeCommand('workbench.action.findInFiles');
vscode.commands.executeCommand('workbench.action.search.toggleQueryDetails');
vscode.commands.executeCommand('workbench.action.search.toggleQueryDetails');
vscode.commands.executeCommand('editor.action.clipboardPasteAction');
vscode.commands.executeCommand('toggleSearchWholeWord');
vscode.commands.executeCommand('toggleSearchWholeWord');
vscode.commands.executeCommand('workbench.action.findInFiles', {
query: name,
triggerSearch: true,
matchWholeWord: matchWholeWord,
isCaseSensitive: matchCase,
});
});
}
});
context.subscriptions.push(disposable);
context.subscriptions.push(searchFileName);
}

function activate(context) {
addCommand(context, 'extension.searchFileName', false, false);
addCommand(context, 'extension.searchFileName.matchCase', true, false);
addCommand(context, 'extension.searchFileName.matchWholeWord', false, true);
addCommand(context, 'extension.searchFileName.matchCaseAndWholeWord', true, true);
}
exports.activate = activate;

Expand Down
Binary file modified images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 2 additions & 4 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"lib": [
"es6"
]
"target": "es2019",
"lib": ["ES2019"]
},
"exclude": [
"node_modules"
Expand Down
45 changes: 34 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,48 @@
"url": "https://github.com/ShawnLin013/vscode-file-name-search.git"
},
"engines": {
"vscode": "^1.17.0"
"vscode": "^1.34.0"
},
"categories": [
"Other"
],
"activationEvents": [
"onCommand:extension.searchFileName"
"onCommand:extension.searchFileName",
"onCommand:extension.searchFileName.matchCase",
"onCommand:extension.searchFileName.matchWholeWord",
"onCommand:extension.searchFileName.matchCaseAndWholeWord"
],
"main": "./extension",
"contributes": {
"commands": [
{
"command": "extension.searchFileName",
"title": "Search File Name"
"title": "%extension.searchFileName%"
}, {
"command": "extension.searchFileName.matchCase",
"title": "%extension.searchFileName.matchCase%"
}, {
"command": "extension.searchFileName.matchWholeWord",
"title": "%extension.searchFileName.matchWholeWord%"
}, {
"command": "extension.searchFileName.matchCaseAndWholeWord",
"title": "%extension.searchFileName.matchCaseAndWholeWord%"
}
],
"menus": {
"explorer/context": [
{
"command": "extension.searchFileName",
"group": "navigation"
"group": "4_search"
}, {
"command": "extension.searchFileName.matchCase",
"group": "4_search"
}, {
"command": "extension.searchFileName.matchWholeWord",
"group": "4_search"
}, {
"command": "extension.searchFileName.matchCaseAndWholeWord",
"group": "4_search"
}
]
}
Expand All @@ -44,11 +65,13 @@
"copy-paste": "^1.3.0"
},
"devDependencies": {
"typescript": "^2.5.2",
"vscode": "^1.1.5",
"mocha": "^3.5.0",
"eslint": "^4.6.1",
"@types/node": "^7.0.0",
"@types/mocha": "^2.2.42"
}
"@types/node": "^12.12.0",
"@types/vscode": "^1.34.0",
"@typescript-eslint/eslint-plugin": "^3.0.2",
"@typescript-eslint/parser": "^3.0.2",
"eslint": "^7.1.0",
"typescript": "^4.0.2",
"mocha": "^8.1.3",
"@types/mocha": "^8.0.3"
}
}
6 changes: 6 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extension.searchFileName": "Search File Name",
"extension.searchFileName.matchCase": "Search File Name (Match Case)",
"extension.searchFileName.matchWholeWord": "Search File Name (Match Whole Word)",
"extension.searchFileName.matchCaseAndWholeWord": "Search File Name (Match Case and Whole Word)"
}
6 changes: 6 additions & 0 deletions package.nls.zh-tw.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extension.searchFileName": "搜尋檔案名稱",
"extension.searchFileName.matchCase": "搜尋檔案名稱 (大小寫須相符)",
"extension.searchFileName.matchWholeWord": "搜尋檔案名稱 (全字拼寫須相符)",
"extension.searchFileName.matchCaseAndWholeWord": "搜尋檔案名稱 (大小寫和全字拼寫皆須相符)"
}

0 comments on commit 3e76c16

Please sign in to comment.