Skip to content

Commit 72f734b

Browse files
authored
Merge pull request microsoft#159617 from microsoft/tyriar/lgtm
Action lgtm.io alerts in terminal
2 parents 963bd98 + 436b356 commit 72f734b

File tree

7 files changed

+12
-14
lines changed

7 files changed

+12
-14
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ export function terminalIconsEqual(iconOne?: TerminalIcon, iconTwo?: TerminalIco
9393
if (ThemeIcon.isThemeIcon(iconOne) && ThemeIcon.isThemeIcon(iconTwo)) {
9494
return iconOne.id === iconTwo.id && iconOne.color === iconTwo.color;
9595
}
96-
if (typeof iconOne === 'object' && iconOne && 'light' in iconOne && 'dark' in iconOne
97-
&& typeof iconTwo === 'object' && iconTwo && 'light' in iconTwo && 'dark' in iconTwo) {
96+
if (typeof iconOne === 'object' && 'light' in iconOne && 'dark' in iconOne
97+
&& typeof iconTwo === 'object' && 'light' in iconTwo && 'dark' in iconTwo) {
9898
const castedIcon = (iconOne as { light: unknown; dark: unknown });
9999
const castedIconTwo = (iconTwo as { light: unknown; dark: unknown });
100100
if ((URI.isUri(castedIcon.light) || isUriComponents(castedIcon.light)) && (URI.isUri(castedIcon.dark) || isUriComponents(castedIcon.dark))

src/vs/platform/terminal/node/ptyService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ export class PtyService extends Disposable implements IPtyService {
381381
const persistentProcess = this._throwIfNoPty(persistentProcessId);
382382
const processDetails = persistentProcess && await this._buildProcessDetails(t.terminal, persistentProcess, revivedPtyId !== undefined);
383383
return {
384-
terminal: { ...processDetails, id: persistentProcessId } ?? null,
384+
terminal: { ...processDetails, id: persistentProcessId },
385385
relativeSize: t.relativeSize
386386
};
387387
} catch (e) {

src/vs/platform/terminal/node/terminalEnvironment.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,8 @@ export function getShellIntegrationInjection(
133133
if (!newArgs) {
134134
return undefined;
135135
}
136-
if (newArgs) {
137-
newArgs = [...newArgs]; // Shallow clone the array to avoid setting the default array
138-
newArgs[newArgs.length - 1] = format(newArgs[newArgs.length - 1], appRoot, '');
139-
}
136+
newArgs = [...newArgs]; // Shallow clone the array to avoid setting the default array
137+
newArgs[newArgs.length - 1] = format(newArgs[newArgs.length - 1], appRoot, '');
140138
return { newArgs, envMixin };
141139
}
142140
logService.warn(`Shell integration cannot be enabled for executable "${shellLaunchConfig.executable}" and args`, shellLaunchConfig.args);

src/vs/platform/terminal/node/terminalProfiles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ async function detectAvailableWindowsProfiles(
122122

123123
const resultProfiles: ITerminalProfile[] = await transformToTerminalProfiles(detectedProfiles.entries(), defaultProfileName, fsProvider, shellEnv, logService, variableResolver);
124124

125-
if (includeDetectedProfiles || (!includeDetectedProfiles && useWslProfiles)) {
125+
if (includeDetectedProfiles || useWslProfiles) {
126126
try {
127127
const result = await getWslProfiles(`${system32Path}\\${useWSLexe ? 'wsl' : 'bash'}.exe`, defaultProfileName);
128128
for (const wslProfile of result) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export class TerminalProfileQuickpick {
124124
if (!name) {
125125
return;
126126
}
127-
const newConfigValue: { [key: string]: ITerminalProfileObject } = { ...configProfiles } ?? {};
127+
const newConfigValue: { [key: string]: ITerminalProfileObject } = { ...configProfiles };
128128
newConfigValue[name] = {
129129
path: context.item.profile.path,
130130
args: context.item.profile.args
@@ -223,7 +223,7 @@ export class TerminalProfileQuickpick {
223223
}
224224
const argsString = profile.args.map(e => {
225225
if (e.includes(' ')) {
226-
return `"${e.replace('/"/g', '\\"')}"`;
226+
return `"${e.replace(/"/g, '\\"')}"`;
227227
}
228228
return e;
229229
}).join(' ');

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export abstract class BaseTerminalProfileResolverService implements ITerminalPro
195195
if (URI.isUri(icon) || isUriComponents(icon)) {
196196
return URI.revive(icon);
197197
}
198-
if (typeof icon === 'object' && icon && 'light' in icon && 'dark' in icon) {
198+
if (typeof icon === 'object' && 'light' in icon && 'dark' in icon) {
199199
const castedIcon = (icon as { light: unknown; dark: unknown });
200200
if ((URI.isUri(castedIcon.light) || isUriComponents(castedIcon.light)) && (URI.isUri(castedIcon.dark) || isUriComponents(castedIcon.dark))) {
201201
return { light: URI.revive(castedIcon.light), dark: URI.revive(castedIcon.dark) };
@@ -469,7 +469,7 @@ export abstract class BaseTerminalProfileResolverService implements ITerminalPro
469469
}
470470

471471
private _isValidAutomationProfile(profile: unknown, os: OperatingSystem): profile is ITerminalProfile {
472-
if (!profile === undefined || typeof profile !== 'object' || profile === null) {
472+
if (profile === null || profile === undefined || typeof profile !== 'object') {
473473
return false;
474474
}
475475
if ('path' in profile && typeof (profile as { path: unknown }).path === 'string') {
@@ -497,7 +497,7 @@ export abstract class BaseTerminalProfileResolverService implements ITerminalPro
497497
await this._configurationService.updateValue(TerminalSettingPrefix.DefaultProfile + this._primaryBackendOs, profile);
498498
this._logService.trace(`migrated from shell/shellArgs, using existing profile ${profile}`);
499499
} else {
500-
const profiles = { ...this._configurationService.inspect<Readonly<{ [key: string]: ITerminalProfileObject }>>(TerminalSettingPrefix.Profiles + this._primaryBackendOs).userValue } || {};
500+
const profiles = { ...this._configurationService.inspect<Readonly<{ [key: string]: ITerminalProfileObject }>>(TerminalSettingPrefix.Profiles + this._primaryBackendOs).userValue };
501501
const profileConfig: ITerminalProfileObject = { path: profile.path };
502502
if (profile.args) {
503503
profileConfig.args = profile.args;

src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, II
394394
let endSpaces = 0;
395395
// line.length may exceed cols as it doesn't necessarily trim the backing array on resize
396396
for (let i = Math.min(line.length, this.raw.cols) - 1; i >= 0; i--) {
397-
if (line && !line?.getCell(i)?.getChars()) {
397+
if (!line?.getCell(i)?.getChars()) {
398398
endSpaces++;
399399
} else {
400400
break;

0 commit comments

Comments
 (0)