-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathextension.ts
48 lines (39 loc) · 1.32 KB
/
extension.ts
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
import * as vscode from 'vscode'
import { createCommands } from './commands'
import * as telemetry from './services/telemetry'
let onDeactivate = () => {
/* placeholder for unsubscribing fn */
}
// activate run on vscode extension initialization
export const activate = (vscodeExt: vscode.ExtensionContext): void => {
// set out default 60/40 layout
vscode.commands.executeCommand('vscode.setEditorLayout', {
orientation: 0,
groups: [{ size: 0.6 }, { size: 0.4 }],
})
// commands
const commands = createCommands({
extensionPath: vscodeExt.extensionPath,
// NOTE: local storage must be bound to the vscodeExt.workspaceState
workspaceState: vscodeExt.workspaceState,
})
const subscribe = (sub: any) => {
vscodeExt.subscriptions.push(sub)
}
// register commands
for (const cmd in commands) {
const command: vscode.Disposable = vscode.commands.registerCommand(cmd, commands[cmd])
subscribe(command)
}
telemetry.activate(subscribe)
onDeactivate = () => {
// cleanup subscriptions/tasks
// handled within activate because it requires access to subscriptions
for (const disposable of vscodeExt.subscriptions) {
disposable.dispose()
}
telemetry.deactivate()
}
}
// deactivate run on vscode extension shut down
export const deactivate = (): void => onDeactivate()