vscode-copy-relative-path
vscode-copy-relative-path copied to clipboard
Support file multiple selection
By modifying the older brother's code, it has been tested and I hope you can add this part of the code.
But how do I contribute code?
vscode-copy-relative-path/extension.js:
function activate(context) {
var disposable = vscode.commands.registerCommand('copyRelativePath', function (uri_first, uris) {
var copied = '';//the previous copy
if (!uris.length) {//when editor/title/context did not receive the uris
uris = [uri_first];
}
for (i in uris) {
var uri = uris[i];
if (typeof uri === 'undefined') {
if (vscode.window.activeTextEditor) {
uri = vscode.window.activeTextEditor.document.uri;
}
}
if (!uri) {
vscode.window.showErrorMessage('Cannot copy relative path, as there appears no file is opened (or it is very large');
return;
}
var path = vscode.workspace.asRelativePath(uri);
path = path.replace(/\\/g, '/');
copied = copy(path, false, copied);
}
});
context.subscriptions.push(disposable);
}
vscode-copy-relative-path/node_modules/copy-paste/index.js:
exports.copy = function (text, callback, copied) {
text = (copied ? copied + "\n" : '') + text;
//...
return text;
};