Browse Source

Adds support for sidebar views

main
Keith Daulton 1 year ago
committed by Keith Daulton
parent
commit
8ce9f543a2
2 changed files with 23 additions and 8 deletions
  1. +10
    -5
      package.json
  2. +13
    -3
      src/commands/copyRelativePathToClipboard.ts

+ 10
- 5
package.json View File

@ -9360,19 +9360,19 @@
"group": "1_gitlens@3" "group": "1_gitlens@3"
}, },
{ {
"command": "gitlens.copyShaToClipboard",
"command": "gitlens.copyRelativePathToClipboard",
"when": "editorTextFocus && gitlens:activeFileStatus =~ /blameable/ && config.gitlens.menus.editor.clipboard", "when": "editorTextFocus && gitlens:activeFileStatus =~ /blameable/ && config.gitlens.menus.editor.clipboard",
"group": "2_gitlens@1"
"group": "1_gitlens@4"
}, },
{ {
"command": "gitlens.copyRelativePathToClipboard",
"command": "gitlens.copyShaToClipboard",
"when": "editorTextFocus && gitlens:activeFileStatus =~ /blameable/ && config.gitlens.menus.editor.clipboard", "when": "editorTextFocus && gitlens:activeFileStatus =~ /blameable/ && config.gitlens.menus.editor.clipboard",
"group": "2_gitlens@2"
"group": "2_gitlens@1"
}, },
{ {
"command": "gitlens.copyMessageToClipboard", "command": "gitlens.copyMessageToClipboard",
"when": "editorTextFocus && gitlens:activeFileStatus =~ /blameable/ && config.gitlens.menus.editor.clipboard", "when": "editorTextFocus && gitlens:activeFileStatus =~ /blameable/ && config.gitlens.menus.editor.clipboard",
"group": "2_gitlens@3"
"group": "2_gitlens@2"
} }
], ],
"editor/title": [ "editor/title": [
@ -12098,6 +12098,11 @@
"group": "2_gitlens@2" "group": "2_gitlens@2"
}, },
{ {
"command": "gitlens.copyRelativePathToClipboard",
"when": "viewItem =~ /gitlens:(file)\\b/",
"group": "2_gitlens@3"
},
{
"command": "gitlens.graph.copySha", "command": "gitlens.graph.copySha",
"when": "webviewItem =~ /gitlens:(?!stash\\b)/", "when": "webviewItem =~ /gitlens:(?!stash\\b)/",
"group": "1_gitlens@1" "group": "1_gitlens@1"

+ 13
- 3
src/commands/copyRelativePathToClipboard.ts View File

@ -1,8 +1,10 @@
import { env, TextEditor, Uri } from 'vscode';
import type { TextEditor, Uri } from 'vscode';
import { env } from 'vscode';
import { Commands } from '../constants'; import { Commands } from '../constants';
import type { Container } from '../container'; import type { Container } from '../container';
import { command } from '../system/command'; import { command } from '../system/command';
import { ActiveEditorCommand, getCommandUri } from './base';
import type { CommandContext } from './base';
import { ActiveEditorCommand, getCommandUri, isCommandContextViewNodeHasFileCommit } from './base';
@command() @command()
export class CopyRelativePathToClipboardCommand extends ActiveEditorCommand { export class CopyRelativePathToClipboardCommand extends ActiveEditorCommand {
@ -10,6 +12,14 @@ export class CopyRelativePathToClipboardCommand extends ActiveEditorCommand {
super(Commands.CopyRelativePathToClipboard); super(Commands.CopyRelativePathToClipboard);
} }
protected override preExecute(context: CommandContext) {
if (isCommandContextViewNodeHasFileCommit(context)) {
return this.execute(context.editor, context.node.commit.file!.uri);
}
return this.execute(context.editor, context.uri);
}
async execute(editor?: TextEditor, uri?: Uri) { async execute(editor?: TextEditor, uri?: Uri) {
uri = getCommandUri(uri, editor); uri = getCommandUri(uri, editor);
let relativePath = ''; let relativePath = '';
@ -20,7 +30,7 @@ export class CopyRelativePathToClipboardCommand extends ActiveEditorCommand {
} }
} }
void (await env.clipboard.writeText(relativePath));
await env.clipboard.writeText(relativePath);
return undefined; return undefined;
} }
} }

Loading…
Cancel
Save