From 08e0609a6c55d14abfc1d5444241534b660792c9 Mon Sep 17 00:00:00 2001 From: Sirtaki Grek Date: Fri, 7 Feb 2020 17:34:08 +0300 Subject: [PATCH 1/2] added keys and logic for the search immediately after clicking --- README.md | 6 +++++- extension.js | 14 +++++++++++++- package.json | 10 ++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1a8fff0..9c3d3b4 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ![ActiveFileInStatusBar in action](media/ActiveFileInStatusBar.gif) ## Install ## -Install [ActiveFileInStatusBar](https://marketplace.visualstudio.com/items?itemName=RoscoP.ActiveFileInStatusBar) directly from the Visual Studio Code extension gallery. +Install [ActiveFileInStatusBar](https://marketplace.visualstudio.com/items?itemName=RoscoP.ActiveFileInStatusBar) directly from the Visual Studio Code extension gallery. ## Options ## @@ -17,6 +17,10 @@ Install [ActiveFileInStatusBar](https://marketplace.visualstudio.com/items?itemN "ActiveFileInStatusBar.revealFile": false, // Set text color for the filename in the status bar. "ActiveFileInStatusBar.color": "", +// Do I need to search immediately after copying. +"ActiveFileInStatusBar.searchАfterСopy": false, +// Regex mask if you need to dissect the path before copying. +"ActiveFileInStatusBar.regexPath": "string", ``` ## Contribute ## diff --git a/extension.js b/extension.js index a52a404..96fde88 100644 --- a/extension.js +++ b/extension.js @@ -59,7 +59,19 @@ function activate(context) { vscode.commands.executeCommand('workbench.action.files.revealActiveFileInWindows') } else { - copypaste.copy(sb.text) + copypaste.copy( + config.regexPath + ? new RegExp(config.regexPath).exec(sb.text) + : sb.text + ) + + if (config.searchАfterСopy) { + vscode.commands.executeCommand('workbench.view.search'); + + setTimeout(() => { + vscode.commands.executeCommand('editor.action.clipboardPasteAction'); + }, 100); + } } }); context.subscriptions.push(disposable); diff --git a/package.json b/package.json index 177db25..4c5a678 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,16 @@ "type": "string", "default": "", "description": "Set text color for the filename in the status bar." + }, + "ActiveFileInStatusBar.searchАfterСopy": { + "type": "boolean", + "default": false, + "description": "Do I need to search immediately after copying." + }, + "ActiveFileInStatusBar.regexPath": { + "type": "string", + "default": "", + "description": "Regex mask if you need to dissect the path before copying." } } } From dab0a9e125cfd3fe0b50a7fa94a4e0266eaa99bc Mon Sep 17 00:00:00 2001 From: Sirtaki Grek Date: Sun, 9 Feb 2020 17:55:28 +0300 Subject: [PATCH 2/2] fix regex path --- README.md | 2 +- extension.js | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9c3d3b4..798b41e 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Install [ActiveFileInStatusBar](https://marketplace.visualstudio.com/items?itemN // Do I need to search immediately after copying. "ActiveFileInStatusBar.searchАfterСopy": false, // Regex mask if you need to dissect the path before copying. -"ActiveFileInStatusBar.regexPath": "string", +"ActiveFileInStatusBar.regex": "string", ``` ## Contribute ## diff --git a/extension.js b/extension.js index 96fde88..edac0c8 100644 --- a/extension.js +++ b/extension.js @@ -60,8 +60,8 @@ function activate(context) { } else { copypaste.copy( - config.regexPath - ? new RegExp(config.regexPath).exec(sb.text) + config.regex + ? sb.text.replace(new RegExp(config.regex), '$1') : sb.text ) diff --git a/package.json b/package.json index 4c5a678..3c16ded 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "default": false, "description": "Do I need to search immediately after copying." }, - "ActiveFileInStatusBar.regexPath": { + "ActiveFileInStatusBar.regex": { "type": "string", "default": "", "description": "Regex mask if you need to dissect the path before copying."