Skip to content

Commit 3802fb5

Browse files
Fixes custom autolinks not being detected (closes #3899)
- Ensures that custom autolinks are loaded in the constructor - Fixes bug with config check when collecting refsets
1 parent 03229d2 commit 3802fb5

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

src/autolinks/autolinks.ts

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class Autolinks implements Disposable {
4242
constructor(private readonly container: Container) {
4343
this._disposable = Disposable.from(configuration.onDidChange(this.onConfigurationChanged, this));
4444

45-
this.onConfigurationChanged();
45+
this.setAutolinksFromConfig();
4646
}
4747

4848
dispose() {
@@ -51,21 +51,25 @@ export class Autolinks implements Disposable {
5151

5252
private onConfigurationChanged(e?: ConfigurationChangeEvent) {
5353
if (configuration.changed(e, 'autolinks')) {
54-
const autolinks = configuration.get('autolinks');
55-
// Since VS Code's configuration objects are live we need to copy them to avoid writing back to the configuration
56-
this._references =
57-
autolinks
58-
?.filter(a => a.prefix && a.url)
59-
?.map(a => ({
60-
prefix: a.prefix,
61-
url: a.url,
62-
alphanumeric: a.alphanumeric ?? false,
63-
ignoreCase: a.ignoreCase ?? false,
64-
title: a.title ?? undefined,
65-
})) ?? [];
54+
this.setAutolinksFromConfig();
6655
}
6756
}
6857

58+
private setAutolinksFromConfig() {
59+
const autolinks = configuration.get('autolinks');
60+
// Since VS Code's configuration objects are live we need to copy them to avoid writing back to the configuration
61+
this._references =
62+
autolinks
63+
?.filter(a => a.prefix && a.url)
64+
?.map(a => ({
65+
prefix: a.prefix,
66+
url: a.url,
67+
alphanumeric: a.alphanumeric ?? false,
68+
ignoreCase: a.ignoreCase ?? false,
69+
title: a.title ?? undefined,
70+
})) ?? [];
71+
}
72+
6973
/** Collects connected integration autolink references into @param refsets */
7074
private async collectIntegrationAutolinks(remote: GitRemote | undefined, refsets: RefSet[]): Promise<void> {
7175
const integrationPromises: Promise<HostingIntegration | IssueIntegration | undefined>[] =
@@ -111,8 +115,12 @@ export class Autolinks implements Disposable {
111115
}
112116

113117
/** Collects custom-configured autolink references into @param refsets */
114-
private collectCustomAutolinks(remote: GitRemote | undefined, refsets: RefSet[]): void {
115-
if (this._references.length && remote?.provider == null) {
118+
private collectCustomAutolinks(
119+
remote: GitRemote | undefined,
120+
refsets: RefSet[],
121+
options?: { excludeCustom?: boolean },
122+
): void {
123+
if (this._references.length && (remote?.provider == null || !options?.excludeCustom)) {
116124
refsets.push([undefined, this._references]);
117125
}
118126
}
@@ -122,9 +130,7 @@ export class Autolinks implements Disposable {
122130

123131
await this.collectIntegrationAutolinks(remote, refsets);
124132
this.collectRemoteAutolinks(remote, refsets);
125-
if (!options?.excludeCustom) {
126-
this.collectCustomAutolinks(remote, refsets);
127-
}
133+
this.collectCustomAutolinks(remote, refsets, options);
128134

129135
return refsets;
130136
}

0 commit comments

Comments
 (0)