-
Notifications
You must be signed in to change notification settings - Fork 2
/
extension.js
36 lines (31 loc) · 892 Bytes
/
extension.js
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
const matchmaker = require("./matchmaker")
const vscode = require("vscode")
/**
* @param {vscode.ExtensionContext} context
*/
function activate(context) {
context.subscriptions.push(
vscode.commands.registerCommand("significant-other.toggle", toggle),
)
}
function deactivate() {}
async function toggle() {
const activeTextEditor = vscode.window.activeTextEditor
if (!activeTextEditor) {
vscode.window.showErrorMessage(
"Whoops. You need to open a text file first.",
)
return
}
const activePath = activeTextEditor.document.uri.path
const complementaryPath = await matchmaker.for(activePath).complementaryPath()
if (complementaryPath) {
vscode.window.showTextDocument(vscode.Uri.file(complementaryPath))
} else {
vscode.window.showInformationMessage("No significant other found 😱")
}
}
module.exports = {
activate,
deactivate,
}