Skip to content
This repository was archived by the owner on Jan 10, 2019. It is now read-only.

Commit 23737ae

Browse files
committed
added functions and vars for quick execution feature
1 parent 12e9809 commit 23737ae

File tree

6 files changed

+777
-490
lines changed

6 files changed

+777
-490
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log (vs-script-commands)
22

3+
## 4.11.0 (May 2nd, 2017; quick execution)
4+
5+
* added `$clearHistory`, `$history`, `$removeFromHistory` and `$saveToHistory` functions
6+
* added `$doNotShowResult` [symbol](https://www.typescriptlang.org/docs/handbook/symbols.html)
7+
* added `saveToGlobalHistory` and `saveToHistory` settings
8+
39
## 4.10.0 (May 2nd, 2017; quick execution functions)
410

511
* added `$password()` and `$randomString()` functions for [quick executions](https://github.com/mkloubert/vs-script-commands#quick-execution-)

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ You can define custom settings for the feature:
289289
| `disableHexView` | Do not show binary data in 'hex view'. Default: `(false)` |
290290
| `noResultInfo` | Do not show results of executions. Default: `(false)` |
291291
| `showResultInTab` | Show results in tab instead of a popup or not. Default: `(false)` |
292+
| `saveToGlobalHistory` | Save entries, that are stored automatically, to global history instead to workspace history. Default: `(false)` |
293+
| `saveToHistory` | Automatically save entries to history or not. Default: `(false)` |
292294
| `state` | The initial state value. |
293295

294296
## Documentation [[↑](#table-of-contents)]

package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vs-script-commands",
33
"displayName": "Script Commands",
44
"description": "Adds additional commands to Visual Studio Code that uses scripts (JavaScript) for execution.",
5-
"version": "4.10.0",
5+
"version": "4.11.0",
66
"publisher": "mkloubert",
77
"engines": {
88
"vscode": "^1.6.0"
@@ -398,6 +398,16 @@
398398
"type": "boolean",
399399
"default": false
400400
},
401+
"saveToGlobalHistory": {
402+
"description": "Show results in tab instead of a popup or not.",
403+
"type": "boolean",
404+
"default": false
405+
},
406+
"saveToHistory": {
407+
"description": "Automatically save entries to history or not.",
408+
"type": "boolean",
409+
"default": false
410+
},
401411
"state": {
402412
"description": "The initial state value."
403413
}

src/contracts.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ export interface ActionMessageItem extends vscode.MessageItem {
3737
action: () => void;
3838
}
3939

40+
/**
41+
* A quick pick item based on an action.
42+
*/
43+
export interface ActionQuickPickItem extends vscode.QuickPickItem {
44+
/**
45+
* The action to invoke.
46+
*/
47+
action: () => any;
48+
/**
49+
* Additional data to store in that object.
50+
*/
51+
tag?: any;
52+
}
53+
4054
/**
4155
* The configuration data for that extension.
4256
*/
@@ -69,6 +83,14 @@ export interface Configuration {
6983
* Show result of execution or not.
7084
*/
7185
noResultInfo?: boolean;
86+
/**
87+
* Save entries, that are stored automatically, to global history instead to workspace history.
88+
*/
89+
saveToGlobalHistory?: boolean;
90+
/**
91+
* Automatically save entries to history or not.
92+
*/
93+
saveToHistory?: boolean;
7294
/**
7395
* Show results in tab instead of a popup or not.
7496
*/

src/helpers.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,29 @@ export function distinctArray<T>(arr: T[]): T[] {
155155
});
156156
}
157157

158+
/**
159+
* Removes duplicate entries from an array by using a selector.
160+
*
161+
* @param {T[]} arr The input array.
162+
* @param {Function} selector The selector to use.
163+
*
164+
* @return {T[]} The filtered array.
165+
*/
166+
export function distinctArrayBy<T, U>(arr: T[], selector: (item: T) => U): T[] {
167+
if (!arr) {
168+
return arr;
169+
}
170+
171+
if (!selector) {
172+
selector = (item) => <any>item;
173+
}
174+
175+
return arr.filter((x, i) => {
176+
return arr.map(y => selector(y))
177+
.indexOf( selector(x) ) === i;
178+
});
179+
}
180+
158181
/**
159182
* Returns the value from a "parameter" object.
160183
*

0 commit comments

Comments
 (0)