Selaa lähdekoodia

Fixes #969 adds copy relative path to context menu

main
Keith Daulton 2 vuotta sitten
vanhempi
commit
10ec66b914
5 muutettua tiedostoa jossa 48 lisäystä ja 1 poistoa
  1. +3
    -0
      README.md
  2. +17
    -1
      package.json
  3. +1
    -0
      src/commands.ts
  4. +26
    -0
      src/commands/copyRelativePathToClipboard.ts
  5. +1
    -0
      src/constants.ts

+ 3
- 0
README.md Näytä tiedosto

@ -675,6 +675,9 @@ Additionally, these integrations provide commands to copy the URL of or open fil
- Adds an _Add Co-authors_ command (`gitlens.addAuthors`) to add a co-author to the commit message input box
- Adds a _Copy SHA_ command (`gitlens.copyShaToClipboard`) to copy the commit SHA of the current line to the clipboard or from the most recent commit to the current branch, if there is no current editor
- Adds a _Copy Relative Path_ command (`gitlens.copyRelativePathToClipboard`) to copy the relative path, of the active file in the editor, to the clipboard
- Adds a _Copy Message_ command (`gitlens.copyMessageToClipboard`) to copy the commit message of the current line to the clipboard or from the most recent commit to the current branch, if there is no current editor
- Adds a _Copy Current Branch_ command (`gitlens.copyCurrentBranch`) to copy the name of the current branch to the clipboard

+ 17
- 1
package.json Näytä tiedosto

@ -169,6 +169,7 @@
"onCommand:gitlens.copyCurrentBranch",
"onCommand:gitlens.copyMessageToClipboard",
"onCommand:gitlens.copyShaToClipboard",
"onCommand:gitlens.copyRelativePathToClipboard",
"onCommand:gitlens.closeUnchangedFiles",
"onCommand:gitlens.openChangedFiles",
"onCommand:gitlens.openBranchesOnRemote",
@ -5133,6 +5134,12 @@
"icon": "$(copy)"
},
{
"command": "gitlens.copyRelativePathToClipboard",
"title": "Copy Relative Path",
"category": "GitLens",
"icon": "$(copy)"
},
{
"command": "gitlens.closeUnchangedFiles",
"title": "Close Unchanged Files",
"category": "GitLens"
@ -7880,6 +7887,10 @@
"when": "gitlens:activeFileStatus =~ /blameable/"
},
{
"command": "gitlens.copyRelativePathToClipboard",
"when": "gitlens:enabled"
},
{
"command": "gitlens.closeUnchangedFiles",
"when": "gitlens:enabled"
},
@ -9354,9 +9365,14 @@
"group": "2_gitlens@1"
},
{
"command": "gitlens.copyMessageToClipboard",
"command": "gitlens.copyRelativePathToClipboard",
"when": "editorTextFocus && gitlens:activeFileStatus =~ /blameable/ && config.gitlens.menus.editor.clipboard",
"group": "2_gitlens@2"
},
{
"command": "gitlens.copyMessageToClipboard",
"when": "editorTextFocus && gitlens:activeFileStatus =~ /blameable/ && config.gitlens.menus.editor.clipboard",
"group": "2_gitlens@3"
}
],
"editor/title": [

+ 1
- 0
src/commands.ts Näytä tiedosto

@ -6,6 +6,7 @@ export * from './commands/copyCurrentBranch';
export * from './commands/copyDeepLink';
export * from './commands/copyMessageToClipboard';
export * from './commands/copyShaToClipboard';
export * from './commands/copyRelativePathToClipboard';
export * from './commands/createPullRequestOnRemote';
export * from './commands/openDirectoryCompare';
export * from './commands/diffLineWithPrevious';

+ 26
- 0
src/commands/copyRelativePathToClipboard.ts Näytä tiedosto

@ -0,0 +1,26 @@
import { env, TextEditor, Uri } from 'vscode';
import { Commands } from '../constants';
import type { Container } from '../container';
import { command } from '../system/command';
import { ActiveEditorCommand, getCommandUri } from './base';
@command()
export class CopyRelativePathToClipboardCommand extends ActiveEditorCommand {
constructor(private readonly container: Container) {
super(Commands.CopyRelativePathToClipboard);
}
async execute(editor?: TextEditor, uri?: Uri) {
uri = getCommandUri(uri, editor);
let relativePath = '';
if (uri != null) {
const repoPath = this.container.git.getBestRepository(editor)?.uri;
if (repoPath != null) {
relativePath = this.container.git.getRelativePath(uri, repoPath);
}
}
void (await env.clipboard.writeText(relativePath));
return undefined;
}
}

+ 1
- 0
src/constants.ts Näytä tiedosto

@ -105,6 +105,7 @@ export const enum Commands {
CopyRemotePullRequestUrl = 'gitlens.copyRemotePullRequestUrl',
CopyRemoteRepositoryUrl = 'gitlens.copyRemoteRepositoryUrl',
CopyShaToClipboard = 'gitlens.copyShaToClipboard',
CopyRelativePathToClipboard = 'gitlens.copyRelativePathToClipboard',
CreatePullRequestOnRemote = 'gitlens.createPullRequestOnRemote',
DiffDirectory = 'gitlens.diffDirectory',
DiffDirectoryWithHead = 'gitlens.diffDirectoryWithHead',

Ladataan…
Peruuta
Tallenna