-
Notifications
You must be signed in to change notification settings - Fork 0
/
extension.js
33 lines (28 loc) · 1.11 KB
/
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
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
const vscode = require('vscode');
const copy = require('copy-paste').copy;
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
function activate(context) {
var disposable = vscode.commands.registerCommand('copyabsolutepath', function (uri) {
if (typeof uri === 'undefined') {
if (vscode.window.activeTextEditor) {
uri = vscode.window.activeTextEditor.document.uri;
}
}
if (!uri) {
vscode.window.showErrorMessage('Cannot copy absolute path, as there appears no file is opened (or it is very large');
return;
}
var path = uri.path;
path = path.replace(':', '');
copy(path);
});
context.subscriptions.push(disposable);
}
exports.activate = activate;
// this method is called when your extension is deactivated
function deactivate() {
}
exports.deactivate = deactivate;