-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.js
More file actions
91 lines (74 loc) · 2.02 KB
/
Copy pathextension.js
File metadata and controls
91 lines (74 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
const vscode = require("vscode");
/**
* @param {vscode.ExtensionContext} context
*/
function activate(context) {
const commandKeySymbol = {darwin: "⌘", win32: "Ctrl+", linux: "Ctrl+"}[process.platform]
const QuickFoldWhenContext = "LetsMakePaperCranes"
const folds = [
{
label: `Fold (${commandKeySymbol}F)`,
value: "editor.foldRecursively"
},
{
label: `Fold All (${commandKeySymbol}A)`,
value: "editor.foldAll"
},
{
label:`Fold All Except Selected (${commandKeySymbol}X)`,
value: "editor.foldAllExcept"
},
{
label: `Unfold (${commandKeySymbol}U)`,
value: "editor.unfoldRecursively"
},
{
label: `Unfold All (${commandKeySymbol}N)`,
value: "editor.unfoldAll"
},
{
label: `Unfold All Except Selected (${commandKeySymbol}G)`,
value: "editor.unfoldAllExcept"
}
]
let foldPicker;
let commands = [
vscode.commands.registerCommand(
"quickFold.showPicker",
() => {
vscode.commands.executeCommand("setContext", QuickFoldWhenContext, true);
foldPicker = vscode.window.createQuickPick();
foldPicker.placeholder = "Fold ... ?";
foldPicker.items = folds;
foldPicker.onDidChangeSelection(([selection]) => {
vscode.commands.executeCommand(selection.value);
foldPicker.hide();
});
foldPicker.onDidHide(() =>{
foldPicker.dispose()
vscode.commands.executeCommand("setContext", QuickFoldWhenContext, undefined);
});
foldPicker.show();
}),
vscode.commands.registerCommand(
"quickFold.origamiThatShit",
(args) => {
foldPicker.hide();
if (args && args.foldCommand){
vscode.commands.executeCommand(args.foldCommand);
} else {
vscode.window.showInformationMessage(`A fold command is not specified for this keybinding. Please provide a "foldCommand" argument in the keybinding:
"args": {
"foldCommand": "editor.foldRecursively"
}"
`)
}
}),
] // end of commands
context.subscriptions.push(commands);
} // end of activate
function deactivate() {}
module.exports = {
activate,
deactivate,
};