-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathextension.js
More file actions
39 lines (29 loc) · 832 Bytes
/
extension.js
File metadata and controls
39 lines (29 loc) · 832 Bytes
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
const vscode = require('vscode');
const editor = vscode.window.activeTextEditor;
async function GetSelectedText() {
let decorations = [];
let text = editor.document.getText(editor.selection);
let decoded = unicodeToChar(text);
decorations.push(editor.selection)
editor.edit(function (editBuilder) {
editBuilder.replace(editor.selection, decoded);
});
}
function unicodeToChar(text) {
return text.replace(/\\u[\dA-F]{4}/gi,
function (match) {
return String.fromCharCode(parseInt(match.replace(/\\u/g, ''), 16));
});
}
function activate(context) {
let disposable = vscode.commands.registerCommand('udecoder.decode', function () {
GetSelectedText();
});
context.subscriptions.push(disposable);
}
exports.activate = activate;
function deactivate() {}
module.exports = {
activate,
deactivate
}