diff --git a/CHANGELOG.md b/CHANGELOG.md index e2ef644..4cb7afc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,8 @@ All notable changes to the "search" extension will be documented in this file. -Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. +## [2.0.0] -## [Unreleased] - -- Initial release \ No newline at end of file +- Converted extension to TypeScript +- Added ability to search VS Code workspace and VS Code Extensions API site +- Added search highlighted word if an explicit selection hasn't been made \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fc4f36e --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018-2021 Chrissy LeMaire + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED,INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY,WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/dist/extension.js b/dist/extension.js index 6486214..85a745f 100644 --- a/dist/extension.js +++ b/dist/extension.js @@ -1,162 +1 @@ -/******/ (() => { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ([ -/* 0 */, -/* 1 */ -/***/ ((module) => { - -module.exports = require("vscode"); - -/***/ }), -/* 2 */ -/***/ (function(__unused_webpack_module, exports, __webpack_require__) { - - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -__exportStar(__webpack_require__(3), exports); - - -/***/ }), -/* 3 */ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.searcher = void 0; -const vscode = __webpack_require__(1); -const getSelectedText_1 = __webpack_require__(4); -function searcher(template) { - var selectedText = getSelectedText_1.getSelectedText(); - if (!selectedText) { - return; - } - var uriText = encodeURI(selectedText); - var search = vscode.workspace.getConfiguration("search"); - const qt = `queryTemplate.${template}`; - const queryTemplate = search.get(`queryTemplate.${template}`); - var query = queryTemplate.replace("-searchphrase-", uriText); - console.debug(`query is ${queryTemplate}`); - vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(query)); -} -exports.searcher = searcher; - - -/***/ }), -/* 4 */ -/***/ ((__unused_webpack_module, exports, __webpack_require__) => { - - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getSelectedText = void 0; -const vscode = __webpack_require__(1); -function getSelectedText() { - const activeEditor = vscode.window.activeTextEditor; - const activeSelection = activeEditor.selection; - if (activeSelection.isEmpty) { - let cursorPosition = activeEditor.selection.start; - let wordRange = activeEditor.document.getWordRangeAtPosition(cursorPosition); - let highlight = activeEditor.document.getText(wordRange); - console.debug(`no explicitly selected text. highlighted on ${highlight}`); - return highlight; - } - const documentText = activeEditor.document.getText(); - if (!documentText) { - console.debug("bailed on getText"); - return ''; - } - const selStartOffset = activeEditor.document.offsetAt(activeSelection.start); - const selEndOffset = activeEditor.document.offsetAt(activeSelection.end); - var selectedText = documentText.slice(selStartOffset, selEndOffset).trim(); - selectedText = selectedText.replace(/\s\s+/g, ' '); - console.debug(`selected text is ${selectedText}`); - return selectedText; -} -exports.getSelectedText = getSelectedText; - - -/***/ }) -/******/ ]); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -var __webpack_exports__ = {}; -// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. -(() => { -var exports = __webpack_exports__; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.deactivate = exports.activate = void 0; -const vscode = __webpack_require__(1); -const utils_1 = __webpack_require__(2); -function activate(context) { - context.subscriptions.push(vscode.commands.registerTextEditorCommand("extension.docsSearch", () => { - utils_1.searcher("Docs"); - })); - context.subscriptions.push(vscode.commands.registerTextEditorCommand("extension.googleSearch", () => { - utils_1.searcher("Google"); - })); - context.subscriptions.push(vscode.commands.registerTextEditorCommand("extension.dbatoolsSearch", () => { - utils_1.searcher("dbatools"); - })); - context.subscriptions.push(vscode.commands.registerTextEditorCommand("extension.stackSearch", () => { - utils_1.searcher("Stackoverflow"); - })); - context.subscriptions.push(vscode.commands.registerTextEditorCommand("extension.duckSearch", () => { - utils_1.searcher("Duckduckgo"); - })); - context.subscriptions.push(vscode.commands.registerTextEditorCommand("extension.thwackSearch", () => { - utils_1.searcher("Thwack"); - })); - context.subscriptions.push(vscode.commands.registerTextEditorCommand("extension.technetSearch", () => { - utils_1.searcher("Technet"); - })); - context.subscriptions.push(vscode.commands.registerTextEditorCommand("extension.vscodeApiSearch", () => { - utils_1.searcher("VSCodeAPI"); - })); - context.subscriptions.push(vscode.commands.registerCommand('extension.vscodeWorkspaceSearch', () => { - vscode.commands.executeCommand('workbench.action.findInFiles'); - })); -} -exports.activate = activate; -function deactivate() { } -exports.deactivate = deactivate; - -})(); - -module.exports = __webpack_exports__; -/******/ })() -; -//# sourceMappingURL=extension.js.map \ No newline at end of file +(()=>{"use strict";var e={160:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getSelectedText=void 0;const r=o(549);t.getSelectedText=function(){const e=r.window.activeTextEditor,t=e.selection;if(t.isEmpty){let t=e.selection.start,o=e.document.getWordRangeAtPosition(t),r=e.document.getText(o);return console.debug(`no explicitly selected text. highlighted on ${r}`),r}const o=e.document.getText();if(!o)return console.debug("bailed on getText"),"";const s=e.document.offsetAt(t.start),n=e.document.offsetAt(t.end);var c=o.slice(s,n).trim();return c=c.replace(/\s\s+/g," "),console.debug(`selected text is ${c}`),c}},928:function(e,t,o){var r=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[o]}})}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),s=this&&this.__exportStar||function(e,t){for(var o in e)"default"===o||Object.prototype.hasOwnProperty.call(t,o)||r(t,e,o)};Object.defineProperty(t,"__esModule",{value:!0}),s(o(125),t)},125:(e,t,o)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.searcher=void 0;const r=o(549),s=o(160);t.searcher=function(e){var t=s.getSelectedText();if(!t)return;var o=encodeURI(t);const n=r.workspace.getConfiguration("search").get(`queryTemplate.${e}`);var c=n.replace("-searchphrase-",o);console.debug(`query is ${n}`),r.commands.executeCommand("vscode.open",r.Uri.parse(c))}},549:e=>{e.exports=require("vscode")}},t={};function o(r){var s=t[r];if(void 0!==s)return s.exports;var n=t[r]={exports:{}};return e[r].call(n.exports,n,n.exports,o),n.exports}var r={};(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.deactivate=e.activate=void 0;const t=o(549),s=o(928);e.activate=function(e){e.subscriptions.push(t.commands.registerTextEditorCommand("extension.docsSearch",(()=>{s.searcher("Docs")}))),e.subscriptions.push(t.commands.registerTextEditorCommand("extension.googleSearch",(()=>{s.searcher("Google")}))),e.subscriptions.push(t.commands.registerTextEditorCommand("extension.dbatoolsSearch",(()=>{s.searcher("dbatools")}))),e.subscriptions.push(t.commands.registerTextEditorCommand("extension.stackSearch",(()=>{s.searcher("Stackoverflow")}))),e.subscriptions.push(t.commands.registerTextEditorCommand("extension.duckSearch",(()=>{s.searcher("Duckduckgo")}))),e.subscriptions.push(t.commands.registerTextEditorCommand("extension.thwackSearch",(()=>{s.searcher("Thwack")}))),e.subscriptions.push(t.commands.registerTextEditorCommand("extension.technetSearch",(()=>{s.searcher("Technet")}))),e.subscriptions.push(t.commands.registerTextEditorCommand("extension.vscodeApiSearch",(()=>{s.searcher("VSCodeAPI")}))),e.subscriptions.push(t.commands.registerCommand("extension.vscodeWorkspaceSearch",(()=>{t.commands.executeCommand("workbench.action.findInFiles")})))},e.deactivate=function(){}})(),module.exports=r})(); \ No newline at end of file diff --git a/dist/extension.js.map b/dist/extension.js.map index 32dfd74..3f7b4d9 100644 --- a/dist/extension.js.map +++ b/dist/extension.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack://search/external \"vscode\"","webpack://search/./src/utils/index.ts","webpack://search/./src/utils/searcher.ts","webpack://search/./src/utils/getSelectedText.ts","webpack://search/webpack/bootstrap","webpack://search/./src/extension.ts"],"names":[],"mappings":";;;;;;;AAAA,mC;;;;;;;;;;;;;;;;;;ACAA,8CAA2B;;;;;;;;;;ACA3B,sCAAiC;AACjC,iDAAoD;AAEpD,SAAgB,QAAQ,CAAC,QAAgB;IACxC,IA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"version":3,"sources":["webpack://search/./src/utils/getSelectedText.ts","webpack://search/./src/utils/index.ts","webpack://search/./src/utils/searcher.ts","webpack://search/external \"vscode\"","webpack://search/webpack/bootstrap","webpack://search/./src/extension.ts"],"names":["activeEditor","vscode","window","activeTextEditor","activeSelection","selection","isEmpty","cursorPosition","start","wordRange","document","getWordRangeAtPosition","highlight","getText","console","debug","documentText","selStartOffset","offsetAt","selEndOffset","end","selectedText","slice","trim","replace","template","getSelectedText","uriText","encodeURI","queryTemplate","workspace","getConfiguration","get","query","commands","executeCommand","Uri","parse","module","exports","require","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","call","context","subscriptions","push","registerTextEditorCommand","searcher","registerCommand"],"mappings":"kHACA,eAEA,6BACC,MAAMA,EAAeC,EAAOC,OAAOC,iBAC7BC,EAAkBJ,EAAcK,UAEtC,GAAID,EAAgBE,QAAS,CAC5B,IAAIC,EAAiBP,EAAcK,UAAUG,MACzCC,EAAYT,EAAcU,SAASC,uBAAuBJ,GAC1DK,EAAYZ,EAAcU,SAASG,QAAQJ,GAI/C,OAFAK,QAAQC,MAAM,+CAA+CH,KAEtDA,EAGR,MAAMI,EAAehB,EAAcU,SAASG,UAC5C,IAAKG,EAEJ,OADAF,QAAQC,MAAM,qBACP,GAGR,MAAME,EAAiBjB,EAAcU,SAASQ,SAASd,EAAgBI,OACjEW,EAAenB,EAAcU,SAASQ,SAASd,EAAgBgB,KAErE,IAAIC,EAAeL,EAAaM,MAAML,EAAgBE,GAAcI,OAIpE,OAHAF,EAAeA,EAAaG,QAAQ,SAAU,KAC9CV,QAAQC,MAAM,oBAAoBM,KAE3BA,I,8YC9BR,a,iFCAA,eACA,SAEA,oBAAyBI,GACxB,IAAIJ,EAAe,EAAAK,kBAEnB,IAAKL,EACH,OAGF,IAAIM,EAAUC,UAAUP,GAExB,MACMQ,EAFO5B,EAAO6B,UAAUC,iBAAiB,UAEbC,IAAI,iBAAiBP,KACvD,IAAIQ,EAAQJ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import * as vscode from 'vscode';\r\n\r\nexport function getSelectedText(): string {\r\n\tconst activeEditor = vscode.window.activeTextEditor;\r\n\tconst activeSelection = activeEditor!.selection;\r\n\r\n\tif (activeSelection.isEmpty) {\r\n\t\tlet cursorPosition = activeEditor!.selection.start;\r\n\t\tlet wordRange = activeEditor!.document.getWordRangeAtPosition(cursorPosition);\r\n\t\tlet highlight = activeEditor!.document.getText(wordRange);\r\n\r\n\t\tconsole.debug(`no explicitly selected text. highlighted on ${highlight}`);\r\n\r\n\t\treturn highlight;\r\n\t}\r\n\r\n\tconst documentText = activeEditor!.document.getText();\r\n\tif (!documentText) {\r\n\t\tconsole.debug(\"bailed on getText\");\r\n\t\treturn '';\r\n\t}\r\n\r\n\tconst selStartOffset = activeEditor!.document.offsetAt(activeSelection.start);\r\n\tconst selEndOffset = activeEditor!.document.offsetAt(activeSelection.end);\r\n\r\n\tvar selectedText = documentText.slice(selStartOffset, selEndOffset).trim();\r\n\tselectedText = selectedText.replace(/\\s\\s+/g, ' ');\r\n\tconsole.debug(`selected text is ${selectedText}`);\r\n\r\n\treturn selectedText;\r\n}","export * from './searcher';\r\n","import * as vscode from 'vscode';\r\nimport { getSelectedText } from './getSelectedText';\r\n\r\nexport function searcher(template: string) {\r\n\tvar selectedText = getSelectedText();\r\n\r\n\tif (!selectedText) {\r\n\t return;\r\n\t}\r\n \r\n\tvar uriText = encodeURI(selectedText);\r\n\tvar search = vscode.workspace.getConfiguration(\"search\");\r\n\tconst qt = `queryTemplate.${template}`;\r\n\tconst queryTemplate: any = search.get(`queryTemplate.${template}`);\r\n\tvar query = queryTemplate.replace(\"-searchphrase-\", uriText);\r\n\tconsole.debug(`query is ${queryTemplate}`);\r\n vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(query));\r\n }","module.exports = require(\"vscode\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","import * as vscode from 'vscode';\r\nimport { searcher } from './utils';\r\n\r\nexport function activate(context: vscode.ExtensionContext) { \r\n\tcontext.subscriptions.push(vscode.commands.registerTextEditorCommand(\"extension.docsSearch\", () => {\r\n\t\tsearcher(\"Docs\");\r\n\t }));\r\n\tcontext.subscriptions.push(vscode.commands.registerTextEditorCommand(\"extension.googleSearch\",() => {\r\n\t\tsearcher(\"Google\");\r\n\t }));\r\n\tcontext.subscriptions.push(vscode.commands.registerTextEditorCommand(\"extension.dbatoolsSearch\",() => {\r\n\t\tsearcher(\"dbatools\");\r\n\t }));\r\n\tcontext.subscriptions.push(vscode.commands.registerTextEditorCommand(\"extension.stackSearch\",() => {\r\n\t\tsearcher(\"Stackoverflow\");\r\n\t }));\r\n\tcontext.subscriptions.push(vscode.commands.registerTextEditorCommand(\"extension.duckSearch\",() => {\r\n\t\tsearcher(\"Duckduckgo\");\r\n\t }));\r\n\tcontext.subscriptions.push(vscode.commands.registerTextEditorCommand(\"extension.thwackSearch\",() => {\r\n\t\tsearcher(\"Thwack\");\r\n\t }));\r\n\tcontext.subscriptions.push(vscode.commands.registerTextEditorCommand(\"extension.technetSearch\", () => {\r\n\t\tsearcher(\"Technet\");\r\n\t }));\r\n\tcontext.subscriptions.push(vscode.commands.registerTextEditorCommand(\"extension.vscodeApiSearch\", () => {\r\n\t\tsearcher(\"VSCodeAPI\");\r\n\t }));\r\n\tcontext.subscriptions.push(vscode.commands.registerCommand('extension.vscodeWorkspaceSearch', () => {\r\n\t\tvscode.commands.executeCommand('workbench.action.findInFiles');\r\n\t}));\r\n}\r\n\r\nexport function deactivate() {}"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index 7e17412..d72429d 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "version": "2.0.0", "icon": "resources/search.png", "publisher": "dbatools", + "license": "MIT", "engines": { "vscode": "^1.57.0" },