Skip to content

Commit c6eb717

Browse files
authored
Merge pull request #199183 from microsoft/merogge/ext-contributed
allow user defined profile to override extension one, remove unused function
2 parents cda7ef0 + 1680198 commit c6eb717

4 files changed

Lines changed: 5 additions & 47 deletions

File tree

src/vs/platform/terminal/common/terminalPlatformConfiguration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const terminalProfileBaseProperties: IJSONSchemaMap = {
4242
}
4343
},
4444
overrideName: {
45-
description: localize('terminalProfile.overrideName', 'Controls whether or not the profile name overrides the auto detected one.'),
45+
description: localize('terminalProfile.overrideName', 'Whether or not to replace the dynamic terminal title that detects what program is running with the static profile name.'),
4646
type: 'boolean'
4747
},
4848
icon: {

src/vs/workbench/contrib/terminal/browser/terminalProfileResolverService.ts

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteA
1919
import { debounce } from 'vs/base/common/decorators';
2020
import { ThemeIcon } from 'vs/base/common/themables';
2121
import { URI } from 'vs/base/common/uri';
22-
import { equals } from 'vs/base/common/arrays';
2322
import { deepClone } from 'vs/base/common/objects';
24-
import { terminalProfileArgsMatch, isUriComponents } from 'vs/platform/terminal/common/terminalProfiles';
23+
import { isUriComponents } from 'vs/platform/terminal/common/terminalProfiles';
2524
import { ITerminalInstanceService } from 'vs/workbench/contrib/terminal/browser/terminal';
2625

2726
export interface IProfileContextProvider {
@@ -345,48 +344,6 @@ export abstract class BaseTerminalProfileResolverService implements ITerminalPro
345344
}
346345
}
347346

348-
private _isValidShellArgs(shellArgs: unknown, os: OperatingSystem): shellArgs is string | string[] | undefined {
349-
if (shellArgs === undefined) {
350-
return true;
351-
}
352-
if (os === OperatingSystem.Windows && typeof shellArgs === 'string') {
353-
return true;
354-
}
355-
if (Array.isArray(shellArgs) && shellArgs.every(e => typeof e === 'string')) {
356-
return true;
357-
}
358-
return false;
359-
}
360-
361-
async createProfileFromShellAndShellArgs(shell?: unknown, shellArgs?: unknown): Promise<ITerminalProfile | string> {
362-
const detectedProfile = this._terminalProfileService.availableProfiles?.find(p => {
363-
if (p.path !== shell) {
364-
return false;
365-
}
366-
if (p.args === undefined || typeof p.args === 'string') {
367-
return p.args === shellArgs;
368-
}
369-
return p.path === shell && equals(p.args, (shellArgs || []) as string[]);
370-
});
371-
const fallbackProfile = (await this.getDefaultProfile({
372-
remoteAuthority: this._remoteAgentService.getConnection()?.remoteAuthority,
373-
os: this._primaryBackendOs!
374-
}));
375-
fallbackProfile.profileName = `${fallbackProfile.path} (migrated)`;
376-
const profile = detectedProfile || fallbackProfile;
377-
const args = this._isValidShellArgs(shellArgs, this._primaryBackendOs!) ? shellArgs : profile.args;
378-
const createdProfile = {
379-
profileName: profile.profileName,
380-
path: profile.path,
381-
args,
382-
isDefault: true
383-
};
384-
if (detectedProfile && detectedProfile.profileName === createdProfile.profileName && detectedProfile.path === createdProfile.path && terminalProfileArgsMatch(detectedProfile.args, createdProfile.args)) {
385-
return detectedProfile.profileName;
386-
}
387-
return createdProfile;
388-
}
389-
390347
private _isValidAutomationProfile(profile: unknown, os: OperatingSystem): profile is ITerminalProfile {
391348
if (profile === null || profile === undefined || typeof profile !== 'object') {
392349
return false;

src/vs/workbench/contrib/terminal/browser/terminalProfileService.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ export class TerminalProfileService extends Disposable implements ITerminalProfi
5252
return this._availableProfiles || [];
5353
}
5454
get contributedProfiles(): IExtensionTerminalProfile[] {
55-
return this._contributedProfiles || [];
55+
const userConfiguredProfileNames = this._availableProfiles?.map(p => p.profileName) || [];
56+
// Allow a user defined profile to override an extension contributed profile with the same name
57+
return this._contributedProfiles?.filter(p => !userConfiguredProfileNames.includes(p.title)) || [];
5658
}
5759

5860
constructor(

src/vs/workbench/contrib/terminal/common/terminal.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export interface ITerminalProfileResolverService {
5151
getDefaultShellArgs(options: IShellLaunchConfigResolveOptions): Promise<string | string[]>;
5252
getDefaultIcon(): TerminalIcon & ThemeIcon;
5353
getEnvironment(remoteAuthority: string | undefined): Promise<IProcessEnvironment>;
54-
createProfileFromShellAndShellArgs(shell?: unknown, shellArgs?: unknown): Promise<ITerminalProfile | string>;
5554
}
5655

5756
/*

0 commit comments

Comments
 (0)