Ver código fonte

Adds support for sidebar views

main
Keith Daulton 1 ano atrás
committed by Keith Daulton
pai
commit
8ce9f543a2
2 arquivos alterados com 23 adições e 8 exclusões
  1. +10
    -5
      package.json
  2. +13
    -3
      src/commands/copyRelativePathToClipboard.ts

+ 10
- 5
package.json Ver arquivo

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

+ 13
- 3
src/commands/copyRelativePathToClipboard.ts Ver arquivo

@ -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 type { Container } from '../container';
import { command } from '../system/command';
import { ActiveEditorCommand, getCommandUri } from './base';
import type { CommandContext } from './base';
import { ActiveEditorCommand, getCommandUri, isCommandContextViewNodeHasFileCommit } from './base';
@command()
export class CopyRelativePathToClipboardCommand extends ActiveEditorCommand {
@ -10,6 +12,14 @@ export class CopyRelativePathToClipboardCommand extends ActiveEditorCommand {
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) {
uri = getCommandUri(uri, editor);
let relativePath = '';
@ -20,7 +30,7 @@ export class CopyRelativePathToClipboardCommand extends ActiveEditorCommand {
}
}
void (await env.clipboard.writeText(relativePath));
await env.clipboard.writeText(relativePath);
return undefined;
}
}

Carregando…
Cancelar
Salvar