Skip to content

Commit 999ac8c

Browse files
committed
Improves copy support on autolinks in views
- Allows multiselect - Adds "Copy as Markdown" to autolinks - Adds "Copy as Markdown" to contributors
1 parent a1d8b1a commit 999ac8c

File tree

14 files changed

+235
-144
lines changed

14 files changed

+235
-144
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- Adds a _Copy as Markdown_ context menu command to autolinks in the "Autolinked Issues and Pull Requests" section in the _Search & Compare_ view
12+
13+
### Changed
14+
15+
- Improves the _Copy_ context menu command on autolinks in the "Autolinked Issues and Pull Requests" section in the _Search & Compare_ view
16+
- Changes the _Open Issue on Remote_ context menu command on autolinks to _Open URL_ in the "Autolinked Issues and Pull Requests" section in the _Search & Compare_ view
17+
- Changes the _Copy Issue URL_ context menu command on autolinks to _Copy URL_ in the "Autolinked Issues and Pull Requests" section in the _Search & Compare_ view
18+
19+
### Fixed
20+
921
- Fixes [#3299](https://github.com/gitkraken/vscode-gitlens/issues/3299) - Branches view no longer displays text colors for branch status after updating to v15.0.0 or above
1022
- Fixes [#3277](https://github.com/gitkraken/vscode-gitlens/issues/3277) (in pre-release only) - Unable to pull branch when the local branch whose name differs from its tracking branch
1123
- Fixes "hang" in Worktrees view when a worktree is missing
@@ -14,10 +26,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1426

1527
## [15.0.3] - 2024-05-14
1628

29+
### Fixed
30+
1731
- Fixes [#3288](https://github.com/gitkraken/vscode-gitlens/issues/3288) - Branch, Tags, Stashes, Local Branch, and Remote Branch "Markers" Are Missing/Removed From Minimap
1832

1933
## [15.0.2] - 2024-05-14
2034

35+
### Fixed
36+
2137
- Fixes [#3270](https://github.com/gitkraken/vscode-gitlens/issues/3270) - GitLens erroneously thinks certain branches are worktrees under some conditions
2238

2339
## [15.0.1] - 2024-05-14

package.json

Lines changed: 74 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -6582,30 +6582,6 @@
65826582
"icon": "$(gitlens-open-revision)",
65836583
"category": "GitLens"
65846584
},
6585-
{
6586-
"command": "gitlens.openAutolinkUrl",
6587-
"title": "Open Autolink URL",
6588-
"category": "GitLens",
6589-
"icon": "$(globe)"
6590-
},
6591-
{
6592-
"command": "gitlens.copyAutolinkUrl",
6593-
"title": "Copy Autolink URL",
6594-
"category": "GitLens",
6595-
"icon": "$(copy)"
6596-
},
6597-
{
6598-
"command": "gitlens.openIssueOnRemote",
6599-
"title": "Open Issue on Remote",
6600-
"category": "GitLens",
6601-
"icon": "$(globe)"
6602-
},
6603-
{
6604-
"command": "gitlens.copyRemoteIssueUrl",
6605-
"title": "Copy Issue URL",
6606-
"category": "GitLens",
6607-
"icon": "$(copy)"
6608-
},
66096585
{
66106586
"command": "gitlens.openPullRequestOnRemote",
66116587
"title": "Open Pull Request on Remote",
@@ -6885,6 +6861,36 @@
68856861
"category": "GitLens",
68866862
"icon": "$(copy)"
68876863
},
6864+
{
6865+
"command": "gitlens.views.copyAsMarkdown",
6866+
"title": "Copy as Markdown",
6867+
"category": "GitLens",
6868+
"icon": "$(copy)"
6869+
},
6870+
{
6871+
"command": "gitlens.views.copyUrl",
6872+
"title": "Copy URL",
6873+
"category": "GitLens",
6874+
"icon": "$(copy)"
6875+
},
6876+
{
6877+
"command": "gitlens.views.copyUrl.multi",
6878+
"title": "Copy URLs",
6879+
"category": "GitLens",
6880+
"icon": "$(copy)"
6881+
},
6882+
{
6883+
"command": "gitlens.views.openUrl",
6884+
"title": "Open URL",
6885+
"category": "GitLens",
6886+
"icon": "$(globe)"
6887+
},
6888+
{
6889+
"command": "gitlens.views.openUrl.multi",
6890+
"title": "Open URLs",
6891+
"category": "GitLens",
6892+
"icon": "$(globe)"
6893+
},
68886894
{
68896895
"command": "gitlens.views.pruneRemote",
68906896
"title": "Prune",
@@ -10283,22 +10289,6 @@
1028310289
"command": "gitlens.copyRemoteComparisonUrl",
1028410290
"when": "false"
1028510291
},
10286-
{
10287-
"command": "gitlens.openAutolinkUrl",
10288-
"when": "false"
10289-
},
10290-
{
10291-
"command": "gitlens.copyAutolinkUrl",
10292-
"when": "false"
10293-
},
10294-
{
10295-
"command": "gitlens.openIssueOnRemote",
10296-
"when": "false"
10297-
},
10298-
{
10299-
"command": "gitlens.copyRemoteIssueUrl",
10300-
"when": "false"
10301-
},
1030210292
{
1030310293
"command": "gitlens.openPullRequestOnRemote",
1030410294
"when": "false"
@@ -10503,6 +10493,26 @@
1050310493
"command": "gitlens.views.copy",
1050410494
"when": "false"
1050510495
},
10496+
{
10497+
"command": "gitlens.views.copyAsMarkdown",
10498+
"when": "false"
10499+
},
10500+
{
10501+
"command": "gitlens.views.copyUrl",
10502+
"when": "false"
10503+
},
10504+
{
10505+
"command": "gitlens.views.copyUrl.multi",
10506+
"when": "false"
10507+
},
10508+
{
10509+
"command": "gitlens.views.openUrl",
10510+
"when": "false"
10511+
},
10512+
{
10513+
"command": "gitlens.views.openUrl.multi",
10514+
"when": "false"
10515+
},
1050610516
{
1050710517
"command": "gitlens.views.pruneRemote",
1050810518
"when": "false"
@@ -13854,6 +13864,11 @@
1385413864
"when": "listMultiSelection && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:contributor\\b(?!.*?\\b\\+current\\b)/",
1385513865
"group": "1_gitlens_actions@2"
1385613866
},
13867+
{
13868+
"command": "gitlens.views.copyAsMarkdown",
13869+
"when": "viewItem =~ /gitlens:contributor\\b/",
13870+
"group": "7_gitlens_cutcopypaste@2"
13871+
},
1385713872
{
1385813873
"command": "gitlens.copyShaToClipboard",
1385913874
"when": "viewItem =~ /gitlens:commit\\b/",
@@ -14186,40 +14201,39 @@
1418614201
{
1418714202
"command": "gitlens.showSettingsPage!autolinks",
1418814203
"when": "!listMultiSelection && viewItem =~ /gitlens:autolinked:items\\b/",
14189-
"group": "1_gitlens_actions@99"
14204+
"group": "8_gitlens_actions@99"
1419014205
},
1419114206
{
14192-
"command": "gitlens.openIssueOnRemote",
14193-
"when": "viewItem =~ /gitlens:autolinked:issue\\b/",
14207+
"command": "gitlens.views.openUrl",
14208+
"when": "viewItem =~ /gitlens:autolinked:item\\b/",
1419414209
"group": "inline@99",
14195-
"alt": "gitlens.copyRemoteIssueUrl"
14210+
"alt": "gitlens.views.copyUrl"
1419614211
},
1419714212
{
14198-
"command": "gitlens.openIssueOnRemote",
14199-
"when": "!listMultiSelection && viewItem =~ /gitlens:autolinked:issue\\b/",
14213+
"command": "gitlens.views.openUrl",
14214+
"when": "!listMultiSelection && viewItem =~ /gitlens:autolinked:item\\b/",
1420014215
"group": "1_gitlens_actions@99"
1420114216
},
1420214217
{
14203-
"command": "gitlens.copyRemoteIssueUrl",
14204-
"when": "!listMultiSelection && viewItem =~ /gitlens:autolinked:issue\\b/",
14205-
"group": "7_gitlens_cutcopypaste@1"
14206-
},
14207-
{
14208-
"command": "gitlens.openAutolinkUrl",
14209-
"when": "viewItem =~ /gitlens:autolinked:item\\b/",
14210-
"group": "inline@99",
14211-
"alt": "gitlens.copyAutolinkUrl"
14218+
"command": "gitlens.views.openUrl.multi",
14219+
"when": "listMultiSelection && viewItem =~ /gitlens:autolinked:item\\b/",
14220+
"group": "1_gitlens_actions@99"
1421214221
},
1421314222
{
14214-
"command": "gitlens.openAutolinkUrl",
14223+
"command": "gitlens.views.copyUrl",
1421514224
"when": "!listMultiSelection && viewItem =~ /gitlens:autolinked:item\\b/",
14216-
"group": "1_gitlens_actions@99"
14225+
"group": "7_gitlens_cutcopypaste@1"
1421714226
},
1421814227
{
14219-
"command": "gitlens.copyAutolinkUrl",
14220-
"when": "!listMultiSelection && viewItem =~ /gitlens:autolinked:item\\b/",
14228+
"command": "gitlens.views.copyUrl.multi",
14229+
"when": "listMultiSelection && viewItem =~ /gitlens:autolinked:item\\b/",
1422114230
"group": "7_gitlens_cutcopypaste@1"
1422214231
},
14232+
{
14233+
"command": "gitlens.views.copyAsMarkdown",
14234+
"when": "viewItem =~ /gitlens:autolinked:item\\b/",
14235+
"group": "7_gitlens_cutcopypaste@2"
14236+
},
1422314237
{
1422414238
"command": "gitlens.views.openPullRequest",
1422514239
"when": "gitlens:action:openPullRequest > 1 && viewItem =~ /gitlens:pullrequest\\b/",
@@ -15097,7 +15111,7 @@
1509715111
},
1509815112
{
1509915113
"command": "gitlens.views.copy",
15100-
"when": "viewItem =~ /gitlens:(?=(autolinked:issue|branch|commit|contributor|file(?!.*?\\b\\+(staged|unstaged))\\b|folder|history:line|pullrequest|remote|repository|repo-folder|search:results|stash|tag|workspace|worktree)\\b)/",
15114+
"when": "viewItem =~ /gitlens:(?=(autolinked:item\\b|branch|commit|contributor|file(?!.*?\\b\\+(staged|unstaged))\\b|folder|history:line|pullrequest|remote|repository|repo-folder|search:results|stash|tag|workspace|worktree)\\b)/",
1510115115
"group": "7_gitlens_cutcopypaste@1"
1510215116
},
1510315117
{

src/commands.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import './commands/openFileOnRemote';
3838
import './commands/openFileAtRevision';
3939
import './commands/openFileAtRevisionFrom';
4040
import './commands/openOnRemote';
41-
import './commands/openIssueOnRemote';
4241
import './commands/openPullRequestOnRemote';
4342
import './commands/openRepoOnRemote';
4443
import './commands/openRevisionFile';

src/commands/openIssueOnRemote.ts

Lines changed: 0 additions & 45 deletions
This file was deleted.

src/constants.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ export const enum Commands {
154154
CompareWorkingWith = 'gitlens.compareWorkingWith',
155155
ComputingFileAnnotations = 'gitlens.computingFileAnnotations',
156156
ConnectRemoteProvider = 'gitlens.connectRemoteProvider',
157-
CopyAutolinkUrl = 'gitlens.copyAutolinkUrl',
158157
CopyCurrentBranch = 'gitlens.copyCurrentBranch',
159158
CopyDeepLinkToBranch = 'gitlens.copyDeepLinkToBranch',
160159
CopyDeepLinkToCommit = 'gitlens.copyDeepLinkToCommit',
@@ -173,7 +172,6 @@ export const enum Commands {
173172
CopyRemoteFileUrl = 'gitlens.copyRemoteFileUrlToClipboard',
174173
CopyRemoteFileUrlWithoutRange = 'gitlens.copyRemoteFileUrlWithoutRange',
175174
CopyRemoteFileUrlFrom = 'gitlens.copyRemoteFileUrlFrom',
176-
CopyRemoteIssueUrl = 'gitlens.copyRemoteIssueUrl',
177175
CopyRemotePullRequestUrl = 'gitlens.copyRemotePullRequestUrl',
178176
CopyRemoteRepositoryUrl = 'gitlens.copyRemoteRepositoryUrl',
179177
CopyShaToClipboard = 'gitlens.copyShaToClipboard',
@@ -214,7 +212,6 @@ export const enum Commands {
214212
GetStarted = 'gitlens.getStarted',
215213
GKSwitchOrganization = 'gitlens.gk.switchOrganization',
216214
InviteToLiveShare = 'gitlens.inviteToLiveShare',
217-
OpenAutolinkUrl = 'gitlens.openAutolinkUrl',
218215
OpenBlamePriorToChange = 'gitlens.openBlamePriorToChange',
219216
OpenBranchesOnRemote = 'gitlens.openBranchesOnRemote',
220217
OpenBranchOnRemote = 'gitlens.openBranchOnRemote',
@@ -230,7 +227,6 @@ export const enum Commands {
230227
OpenFileAtRevisionFrom = 'gitlens.openFileRevisionFrom',
231228
OpenFolderHistory = 'gitlens.openFolderHistory',
232229
OpenOnRemote = 'gitlens.openOnRemote',
233-
OpenIssueOnRemote = 'gitlens.openIssueOnRemote',
234230
OpenCloudPatch = 'gitlens.openCloudPatch',
235231
OpenPatch = 'gitlens.openPatch',
236232
OpenPullRequestOnRemote = 'gitlens.openPullRequestOnRemote',
@@ -386,8 +382,11 @@ export const enum Commands {
386382
ToggleReviewMode = 'gitlens.toggleReviewMode',
387383
ToggleZenMode = 'gitlens.toggleZenMode',
388384
ViewsCopy = 'gitlens.views.copy',
385+
ViewsCopyAsMarkdown = 'gitlens.views.copyAsMarkdown',
386+
ViewsCopyUrl = 'gitlens.views.copyUrl',
389387
ViewsOpenDirectoryDiff = 'gitlens.views.openDirectoryDiff',
390388
ViewsOpenDirectoryDiffWithWorking = 'gitlens.views.openDirectoryDiffWithWorking',
389+
ViewsOpenUrl = 'gitlens.views.openUrl',
391390

392391
Deprecated_DiffHeadWith = 'gitlens.diffHeadWith',
393392
Deprecated_DiffWorkingWith = 'gitlens.diffWorkingWith',

src/system/array.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,16 @@ export function joinUnique<T>(source: readonly T[], separator: string): string {
204204
return join(new Set(source), separator);
205205
}
206206

207-
export async function mapAsync<T, TMapped>(source: T[], mapper: (item: T) => Promise<TMapped>): Promise<TMapped[]> {
207+
export async function mapAsync<T, TMapped>(
208+
source: T[],
209+
mapper: (item: T) => TMapped | Promise<TMapped>,
210+
predicate?: (item: TMapped) => boolean,
211+
): Promise<NonNullable<TMapped>[]> {
208212
const items = source.map(mapper);
209213

210214
const mapped = [];
211215
for await (const item of items) {
212-
if (item == null) continue;
216+
if (item == null || (predicate != null && !predicate(item))) continue;
213217

214218
mapped.push(item);
215219
}

src/system/function.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,23 @@ export function once<T extends (...args: any[]) => any>(fn: T): T {
177177
} as T;
178178
}
179179

180+
type PartialArgs<T extends any[], P extends any[]> = {
181+
[K in keyof P]: K extends keyof T ? T[K] : never;
182+
};
183+
184+
type DropFirstN<T extends any[], N extends number, I extends any[] = []> = {
185+
0: T;
186+
1: T extends [infer _, ...infer R] ? DropFirstN<R, N, [any, ...I]> : T;
187+
}[I['length'] extends N ? 0 : 1];
188+
189+
export function partial<T extends (...args: any[]) => any, P extends any[]>(
190+
fn: T,
191+
...partialArgs: PartialArgs<Parameters<T>, P>
192+
): (...rest: DropFirstN<Parameters<T>, P['length']>) => ReturnType<T> {
193+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
194+
return (...rest) => fn(...partialArgs, ...rest);
195+
}
196+
180197
export function propOf<T, K extends Extract<keyof T, string>>(o: T, key: K) {
181198
const propOfCore = <T, K extends Extract<keyof T, string>>(o: T, key: K) => {
182199
const value: string =

src/views/nodes/abstract/viewNode.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export const enum ContextValues {
5050
ActiveFileHistory = 'gitlens:history:active:file',
5151
ActiveLineHistory = 'gitlens:history:active:line',
5252
AutolinkedItems = 'gitlens:autolinked:items',
53-
AutolinkedIssue = 'gitlens:autolinked:issue',
5453
AutolinkedItem = 'gitlens:autolinked:item',
5554
Branch = 'gitlens:branch',
5655
Branches = 'gitlens:branches',
@@ -215,6 +214,8 @@ export function getViewNodeId(type: string, context: AmbientContext): string {
215214
return `gitlens://viewnode/${type}${uniqueness}`;
216215
}
217216

217+
export type ClipboardType = 'text' | 'markdown';
218+
218219
@logName<ViewNode>((c, name) => `${name}${c.id != null ? `(${c.id})` : ''}`)
219220
export abstract class ViewNode<
220221
Type extends TreeViewNodeTypes = TreeViewNodeTypes,
@@ -273,7 +274,8 @@ export abstract class ViewNode<
273274
return { ...(reset ? this.parent?.context : this.context), ...context };
274275
}
275276

276-
toClipboard?(): string;
277+
getUrl?(): string | Promise<string | undefined> | undefined;
278+
toClipboard?(type?: ClipboardType): string | Promise<string>;
277279

278280
toString(): string {
279281
const id = this.id;

0 commit comments

Comments
 (0)