Skip to content

Commit f67a582

Browse files
committed
Fixes #1458 - restores range copying
1 parent 7a4b551 commit f67a582

File tree

4 files changed

+50
-16
lines changed

4 files changed

+50
-16
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [Unreleased]
8+
9+
### Added
10+
11+
- Adds an alternate _Copy Remote File Url_ command (`gitlens.copyRemoteFileUrlWithoutRange`) to copy the remote url of the file without including any line range
12+
13+
### Fixed
14+
15+
- Fixes [#1458](https://github.com/eamodio/vscode-gitlens/issues/1458) - "Copy Remote File Url" not showing line ranges
16+
717
## [11.4.0] - 2021-04-08
818

919
### Added

package.json

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160
"onCommand:gitlens.openFileFromRemote",
161161
"onCommand:gitlens.openFileOnRemote",
162162
"onCommand:gitlens.copyRemoteFileUrlToClipboard",
163+
"onCommand:gitlens.copyRemoteFileUrlWithoutRange",
163164
"onCommand:gitlens.openFileOnRemoteFrom",
164165
"onCommand:gitlens.copyRemoteFileUrlFrom",
165166
"onCommand:gitlens.openBlamePriorToChange",
@@ -3726,6 +3727,15 @@
37263727
"light": "images/light/icon-copy-link.svg"
37273728
}
37283729
},
3730+
{
3731+
"command": "gitlens.copyRemoteFileUrlWithoutRange",
3732+
"title": "Copy Remote File Url",
3733+
"category": "GitLens",
3734+
"icon": {
3735+
"dark": "images/dark/icon-copy-link.svg",
3736+
"light": "images/light/icon-copy-link.svg"
3737+
}
3738+
},
37293739
{
37303740
"command": "gitlens.openFileOnRemoteFrom",
37313741
"title": "Open File on Remote From...",
@@ -5614,6 +5624,10 @@
56145624
"command": "gitlens.copyRemoteFileUrlToClipboard",
56155625
"when": "gitlens:activeFileStatus =~ /tracked/ && gitlens:activeFileStatus =~ /remotes/"
56165626
},
5627+
{
5628+
"command": "gitlens.copyRemoteFileUrlWithoutRange",
5629+
"when": "false"
5630+
},
56175631
{
56185632
"command": "gitlens.openFileOnRemoteFrom",
56195633
"when": "gitlens:activeFileStatus =~ /tracked/ && gitlens:activeFileStatus =~ /remotes/"
@@ -6748,7 +6762,7 @@
67486762
],
67496763
"editor/title/context": [
67506764
{
6751-
"command": "gitlens.copyRemoteFileUrlToClipboard",
6765+
"command": "gitlens.copyRemoteFileUrlWithoutRange",
67526766
"when": "gitlens:enabled && gitlens:hasRemotes && config.gitlens.menus.editorTab.clipboard",
67536767
"group": "1_cutcopypaste@100"
67546768
},
@@ -6766,7 +6780,7 @@
67666780
"command": "gitlens.openFileOnRemote",
67676781
"when": "gitlens:enabled && gitlens:hasRemotes && config.gitlens.menus.editorTab.remote",
67686782
"group": "2_gitlens@2",
6769-
"alt": "gitlens.copyRemoteFileUrlToClipboard"
6783+
"alt": "gitlens.copyRemoteFileUrlWithoutRange"
67706784
},
67716785
{
67726786
"command": "gitlens.openFileOnRemoteFrom",
@@ -6795,7 +6809,7 @@
67956809
"command": "gitlens.openFileOnRemote",
67966810
"when": "!explorerResourceIsRoot && !explorerResourceIsFolder && gitlens:enabled && gitlens:hasRemotes && config.gitlens.menus.explorer.remote",
67976811
"group": "4_gitlens@1",
6798-
"alt": "gitlens.copyRemoteFileUrlToClipboard"
6812+
"alt": "gitlens.copyRemoteFileUrlWithoutRange"
67996813
},
68006814
{
68016815
"command": "gitlens.openFileOnRemoteFrom",
@@ -6819,7 +6833,7 @@
68196833
"group": "4_timeline@3"
68206834
},
68216835
{
6822-
"command": "gitlens.copyRemoteFileUrlToClipboard",
6836+
"command": "gitlens.copyRemoteFileUrlWithoutRange",
68236837
"when": "!explorerResourceIsRoot && !explorerResourceIsFolder && gitlens:enabled && gitlens:hasRemotes && config.gitlens.menus.explorer.clipboard",
68246838
"group": "6_copypath@100"
68256839
}
@@ -6892,7 +6906,7 @@
68926906
"command": "gitlens.openFileOnRemote",
68936907
"when": "gitlens:enabled && gitlens:hasRemotes && scmProvider == git && scmResourceGroup =~ /^(workingTree|index|merge)$/ && config.gitlens.menus.scmItem.remote",
68946908
"group": "navigation@96",
6895-
"alt": "gitlens.copyRemoteFileUrlToClipboard"
6909+
"alt": "gitlens.copyRemoteFileUrlWithoutRange"
68966910
},
68976911
{
68986912
"command": "gitlens.openFileOnRemoteFrom",
@@ -6906,7 +6920,7 @@
69066920
"group": "1_modification@2"
69076921
},
69086922
{
6909-
"command": "gitlens.copyRemoteFileUrlToClipboard",
6923+
"command": "gitlens.copyRemoteFileUrlWithoutRange",
69106924
"when": "gitlens:enabled && gitlens:hasRemotes && scmProvider == git && scmResourceGroup =~ /^(workingTree|index|merge)$/ && config.gitlens.menus.scmItem.clipboard",
69116925
"group": "2_gitlens@1"
69126926
},
@@ -7982,7 +7996,7 @@
79827996
"command": "gitlens.openFileOnRemote",
79837997
"when": "viewItem =~ /gitlens:file\\b((?=.*?\\b\\+committed\\b)|:results)/ && gitlens:hasRemotes",
79847998
"group": "inline@99",
7985-
"alt": "gitlens.copyRemoteFileUrlToClipboard"
7999+
"alt": "gitlens.copyRemoteFileUrlWithoutRange"
79868000
},
79878001
{
79888002
"submenu": "gitlens/commit/file/commit",
@@ -8028,7 +8042,7 @@
80288042
"command": "gitlens.openFileOnRemote",
80298043
"when": "viewItem =~ /gitlens:file\\b((?=.*?\\b\\+committed\\b)|:results)/ && gitlens:hasRemotes",
80308044
"group": "2_gitlens_quickopen@5",
8031-
"alt": "gitlens.copyRemoteFileUrlToClipboard"
8045+
"alt": "gitlens.copyRemoteFileUrlWithoutRange"
80328046
},
80338047
{
80348048
"command": "gitlens.openFileHistory",
@@ -8075,7 +8089,7 @@
80758089
"command": "gitlens.openFileOnRemote",
80768090
"when": "viewItem =~ /gitlens:(history:(file|line)|status:file)\\b/ && gitlens:hasRemotes",
80778091
"group": "5_gitlens_open@2",
8078-
"alt": "gitlens.copyRemoteFileUrlToClipboard"
8092+
"alt": "gitlens.copyRemoteFileUrlWithoutRange"
80798093
},
80808094
{
80818095
"command": "gitlens.views.openPullRequest",
@@ -8719,7 +8733,7 @@
87198733
"group": "2_gitlens@1"
87208734
},
87218735
{
8722-
"command": "gitlens.copyRemoteFileUrlToClipboard",
8736+
"command": "gitlens.copyRemoteFileUrlWithoutRange",
87238737
"when": "viewItem =~ /gitlens:(file\\b(?=.*?\\b\\+committed\\b)|history:(file|line)|status:file)\\b/ && gitlens:hasRemotes",
87248738
"group": "2_gitlens@2"
87258739
}

src/commands/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export enum Commands {
4848
CopyRemoteCommitUrl = 'gitlens.copyRemoteCommitUrl',
4949
CopyRemoteComparisonUrl = 'gitlens.copyRemoteComparisonUrl',
5050
CopyRemoteFileUrl = 'gitlens.copyRemoteFileUrlToClipboard',
51+
CopyRemoteFileUrlWithoutRange = 'gitlens.copyRemoteFileUrlWithoutRange',
5152
CopyRemoteFileUrlFrom = 'gitlens.copyRemoteFileUrlFrom',
5253
CopyRemotePullRequestUrl = 'gitlens.copyRemotePullRequestUrl',
5354
CopyRemoteRepositoryUrl = 'gitlens.copyRemoteRepositoryUrl',

src/commands/openFileOnRemote.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand {
3737
Commands.OpenFileOnRemote,
3838
Commands.Deprecated_OpenFileInRemote,
3939
Commands.CopyRemoteFileUrl,
40+
Commands.CopyRemoteFileUrlWithoutRange,
4041
Commands.OpenFileOnRemoteFrom,
4142
Commands.CopyRemoteFileUrlFrom,
4243
]);
@@ -45,12 +46,18 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand {
4546
protected async preExecute(context: CommandContext, args?: OpenFileOnRemoteCommandArgs) {
4647
let uri = context.uri;
4748

48-
if (context.type === 'uris' || context.type === 'scm-states') {
49+
if (context.command === Commands.CopyRemoteFileUrlWithoutRange) {
4950
args = { ...args, range: false };
50-
} else if (isCommandContextViewNodeHasCommit(context)) {
51+
}
52+
53+
if (isCommandContextViewNodeHasCommit(context)) {
5154
args = { ...args, range: false };
5255

53-
if (context.command === Commands.CopyRemoteFileUrl || context.command === Commands.CopyRemoteFileUrlFrom) {
56+
if (
57+
context.command === Commands.CopyRemoteFileUrl ||
58+
context.command === Commands.CopyRemoteFileUrlWithoutRange ||
59+
context.command === Commands.CopyRemoteFileUrlFrom
60+
) {
5461
// If it is a StatusFileNode then don't include the sha, since it hasn't been pushed yet
5562
args.sha = context.node instanceof StatusFileNode ? undefined : context.node.commit.sha;
5663
} else if (isCommandContextViewNodeHasBranch(context)) {
@@ -64,7 +71,11 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand {
6471
uri = context.node.uri ?? context.uri;
6572
}
6673

67-
if (context.command === Commands.CopyRemoteFileUrl || context.command === Commands.CopyRemoteFileUrlFrom) {
74+
if (
75+
context.command === Commands.CopyRemoteFileUrl ||
76+
context.command === Commands.CopyRemoteFileUrlWithoutRange ||
77+
context.command === Commands.CopyRemoteFileUrlFrom
78+
) {
6879
args = { ...args, clipboard: true };
6980
if (args.sha == null) {
7081
const uri = getCommandUri(context.uri, context.editor);
@@ -89,8 +100,6 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand {
89100

90101
if (context.command === Commands.OpenFileOnRemoteFrom || context.command === Commands.CopyRemoteFileUrlFrom) {
91102
args = { ...args, pickBranchOrTag: true, range: false };
92-
} else if (context.command === Commands.CopyRemoteFileUrl && context.type === 'unknown') {
93-
args = { ...args, range: false };
94103
}
95104

96105
return this.execute(context.editor, uri, args);

0 commit comments

Comments
 (0)