Skip to content

Refactor editor #396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 20, 2020
Next Next commit
refactor activate/deactivate
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
ShMcK committed Jul 20, 2020
commit 9139d8fcf8100c8b118c3c1f66b1596f1a534f76
48 changes: 0 additions & 48 deletions src/editor/index.ts

This file was deleted.

46 changes: 41 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@
import Editor from './editor'
import * as vscode from 'vscode'
import { createCommands } from './editor/commands'
import * as telemetry from './services/telemetry'

// vscode editor
export const editor = new Editor()
let onDeactivate = () => {}

// activate run on vscode extension initialization
export const activate = editor.activate
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 = editor.deactivate
export const deactivate = (): void => onDeactivate()