diff --git a/README.md b/README.md index ef1600f..e9be1cf 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/extension.js b/extension.js index 1fe9c7d..fc4cbe0 100644 --- a/extension.js +++ b/extension.js @@ -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; diff --git a/images/logo.png b/images/logo.png index b49d4e8..eab8ac5 100644 Binary files a/images/logo.png and b/images/logo.png differ diff --git a/jsconfig.json b/jsconfig.json index b7caa7d..a4ccfd3 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -1,10 +1,8 @@ { "compilerOptions": { "module": "commonjs", - "target": "es6", - "lib": [ - "es6" - ] + "target": "es2019", + "lib": ["ES2019"] }, "exclude": [ "node_modules" diff --git a/package.json b/package.json index 8aad210..d95072d 100644 --- a/package.json +++ b/package.json @@ -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" } ] } @@ -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" + } } \ No newline at end of file diff --git a/package.nls.json b/package.nls.json new file mode 100644 index 0000000..064c58e --- /dev/null +++ b/package.nls.json @@ -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)" +} \ No newline at end of file diff --git a/package.nls.zh-tw.json b/package.nls.zh-tw.json new file mode 100644 index 0000000..449323b --- /dev/null +++ b/package.nls.zh-tw.json @@ -0,0 +1,6 @@ +{ + "extension.searchFileName": "搜尋檔案名稱", + "extension.searchFileName.matchCase": "搜尋檔案名稱 (大小寫須相符)", + "extension.searchFileName.matchWholeWord": "搜尋檔案名稱 (全字拼寫須相符)", + "extension.searchFileName.matchCaseAndWholeWord": "搜尋檔案名稱 (大小寫和全字拼寫皆須相符)" +} \ No newline at end of file