-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathextension.js
More file actions
41 lines (33 loc) · 1.41 KB
/
extension.js
File metadata and controls
41 lines (33 loc) · 1.41 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
const vscode = require('vscode');
const method = require('./src/method');
const open = require('opn');
function activate(context) {
const statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
const DSelection = vscode.window.onDidChangeTextEditorSelection(() => {
statusBarItem.hide();
});
const DEditor = vscode.window.onDidChangeActiveTextEditor(() => {
statusBarItem.hide();
});
const DMain = vscode.commands.registerCommand('extension.caniuse', () => {
const statusString = method.caniuse();
Promise.resolve(statusString).then((string) => {
statusBarItem.text = string !== '' ? string : `$(search) Unknown prop: search in browser`;
statusBarItem.command = 'extension.browse';
statusBarItem.tooltip = 'Click to search in caniuse website';
statusBarItem.show();
});
});
const DbrowserScope = vscode.commands.registerCommand('extension.setBrowserScope', method.setBrowserScope);
const DCommand = vscode.commands.registerCommand('extension.browse', () => {
open('http://caniuse.com/#search=' + method.getSelectedText());
});
context.subscriptions.push(statusBarItem);
context.subscriptions.push(DSelection);
context.subscriptions.push(DEditor);
context.subscriptions.push(DCommand);
context.subscriptions.push(DbrowserScope);
context.subscriptions.push(DMain);
}
exports.activate = activate;
exports.deactivate = function() {};