Browse Source

Support Linux without requiring external dependency (xclip)

main
Cédric Malard 6 years ago
committed by Eric Amodio
parent
commit
43b87c3fe2
5 changed files with 1054 additions and 1075 deletions
  1. +0
    -5
      README.md
  2. +1042
    -1031
      package-lock.json
  3. +2
    -2
      package.json
  4. +5
    -18
      src/commands/copyMessageToClipboard.ts
  5. +5
    -19
      src/commands/copyShaToClipboard.ts

+ 0
- 5
README.md View File

@ -797,11 +797,6 @@ GitLens defines a set of themable colors which can be provided by vscode themes
Add [`"gitlens.insiders": true`](#general-settings "Jump to GitLens settings") to your settings to join the insiders channel and get early access to upcoming features. Be aware that because this provides early access expect there to be issues.
---
## Known Issues
- If the `Copy to * clipboard` commands don't work on Linux — `xclip` needs to be installed. You can install it via `sudo apt-get install xclip`
---
## Contributors 🙏❤
A big thanks to the people that have contributed to this project:

+ 1042
- 1031
package-lock.json
File diff suppressed because it is too large
View File


+ 2
- 2
package.json View File

@ -3232,7 +3232,7 @@
"vscode:prepublish": "npm run reset && npm run bundle"
},
"dependencies": {
"copy-paste": "1.3.0",
"clipboardy": "1.2.3",
"date-fns": "1.29.0",
"iconv-lite": "0.4.23",
"lodash.debounce": "4.0.8",
@ -3241,7 +3241,7 @@
"tslib": "1.9.2"
},
"devDependencies": {
"@types/copy-paste": "1.1.30",
"@types/clipboardy": "1.1.0",
"@types/node": "7.0.65",
"@types/tmp": "0.0.33",
"husky": "0.14.3",

+ 5
- 18
src/commands/copyMessageToClipboard.ts View File

@ -30,7 +30,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
async execute(editor?: TextEditor, uri?: Uri, args: CopyMessageToClipboardCommandArgs = {}): Promise<any> {
uri = getCommandUri(uri, editor);
const clipboard = await import('copy-paste');
const clipboard = await import('clipboardy');
try {
args = { ...args };
@ -44,13 +44,10 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
if (!log) return undefined;
args.message = Iterables.first(log.commits.values()).message;
clipboard.copy(args.message);
return undefined;
}
else if (args.message === undefined) {
const gitUri = await GitUri.fromUri(uri);
const gitUri = await GitUri.fromUri(uri);
if (args.message === undefined) {
if (args.sha === undefined) {
const blameline = (editor && editor.selection.active.line) || 0;
if (blameline < 0) return undefined;
@ -81,17 +78,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
args.message = commit.message;
}
clipboard.copy(args.message, (err: Error) => {
if (err) {
if (err.message.includes('xclip')) {
window.showErrorMessage(`Unable to copy message, xclip is not installed. You can install it via \`sudo apt-get install xclip\``);
return;
}
Logger.error(err, 'CopyMessageToClipboardCommand');
window.showErrorMessage(`Unable to copy message. See output channel for more details`);
}
});
clipboard.write(args.message);
return undefined;
}
catch (ex) {
@ -99,4 +86,4 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
return window.showErrorMessage(`Unable to copy message. See output channel for more details`);
}
}
}
}

+ 5
- 19
src/commands/copyShaToClipboard.ts View File

@ -29,7 +29,7 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
async execute(editor?: TextEditor, uri?: Uri, args: CopyShaToClipboardCommandArgs = {}): Promise<any> {
uri = getCommandUri(uri, editor);
const clipboard = await import('copy-paste');
const clipboard = await import('clipboardy');
try {
args = { ...args };
@ -42,17 +42,13 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
if (!log) return undefined;
args.sha = Iterables.first(log.commits.values()).sha;
clipboard.copy(args.sha);
return undefined;
}
const gitUri = await GitUri.fromUri(uri);
if (args.sha === undefined) {
else if (args.sha === undefined) {
const blameline = (editor && editor.selection.active.line) || 0;
if (blameline < 0) return undefined;
try {
const gitUri = await GitUri.fromUri(uri);
const blame = editor && editor.document && editor.document.isDirty
? await Container.git.getBlameForLineContents(gitUri, blameline, editor.document.getText())
: await Container.git.getBlameForLine(gitUri, blameline);
@ -66,17 +62,7 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
}
}
clipboard.copy(args.sha, (err: Error) => {
if (err) {
if (err.message.includes('xclip')) {
window.showErrorMessage(`Unable to copy commit id, xclip is not installed. You can install it via \`sudo apt-get install xclip\``);
return;
}
Logger.error(err, 'CopyShaToClipboardCommand');
window.showErrorMessage(`Unable to copy commit id. See output channel for more details`);
}
});
clipboard.write(args.sha);
return undefined;
}
catch (ex) {
@ -84,4 +70,4 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
return window.showErrorMessage(`Unable to copy commit id. See output channel for more details`);
}
}
}
}

Loading…
Cancel
Save