Skip to content

Commit aec79b9

Browse files
committed
Strict null check terminalConfigHelper
Part of microsoft#60565
1 parent cfc830c commit aec79b9

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

src/tsconfig.strictNullChecks.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@
659659
"./vs/workbench/parts/terminal/common/terminalCommands.ts",
660660
"./vs/workbench/parts/terminal/common/terminalMenu.ts",
661661
"./vs/workbench/parts/terminal/common/terminalService.ts",
662+
"./vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts",
662663
"./vs/workbench/parts/terminal/node/terminal.ts",
663664
"./vs/workbench/parts/terminal/node/terminalCommandTracker.ts",
664665
"./vs/workbench/parts/terminal/node/terminalEnvironment.ts",

src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
5151
public configFontIsMonospace(): boolean {
5252
this._createCharMeasureElementIfNecessary();
5353
const fontSize = 15;
54-
const fontFamily = this.config.fontFamily || this._configurationService.getValue<IEditorOptions>('editor').fontFamily;
54+
const fontFamily = this.config.fontFamily || this._configurationService.getValue<IEditorOptions>('editor').fontFamily || EDITOR_FONT_DEFAULTS.fontFamily;
5555
const i_rect = this._getBoundingRectFor('i', fontFamily, fontSize);
5656
const w_rect = this._getBoundingRectFor('w', fontFamily, fontSize);
5757

@@ -113,7 +113,7 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
113113
public getFont(xterm?: XTermTerminal, excludeDimensions?: boolean): ITerminalFont {
114114
const editorConfig = this._configurationService.getValue<IEditorOptions>('editor');
115115

116-
let fontFamily = this.config.fontFamily || editorConfig.fontFamily;
116+
let fontFamily = this.config.fontFamily || editorConfig.fontFamily || EDITOR_FONT_DEFAULTS.fontFamily;
117117
let fontSize = this._toInteger(this.config.fontSize, MINIMUM_FONT_SIZE, MAXIMUM_FONT_SIZE, EDITOR_FONT_DEFAULTS.fontSize);
118118

119119
// Work around bad font on Fedora/Ubuntu
@@ -170,7 +170,7 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
170170
const shellArgsConfigValue = this._workspaceConfigurationService.inspect<string[]>(`terminal.integrated.shellArgs.${platformKey}`);
171171

172172
// Check if workspace setting exists and whether it's whitelisted
173-
let isWorkspaceShellAllowed = false;
173+
let isWorkspaceShellAllowed: boolean | undefined = false;
174174
if (shellConfigValue.workspace !== undefined || shellArgsConfigValue.workspace !== undefined) {
175175
isWorkspaceShellAllowed = this._storageService.getBoolean(IS_WORKSPACE_SHELL_ALLOWED_STORAGE_KEY, StorageScope.WORKSPACE, undefined);
176176
}
@@ -183,18 +183,18 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
183183
// Check if the value is neither blacklisted (false) or whitelisted (true) and ask for
184184
// permission
185185
if (isWorkspaceShellAllowed === undefined) {
186-
let shellString: string;
186+
let shellString: string | undefined;
187187
if (shellConfigValue.workspace) {
188188
shellString = `"${shellConfigValue.workspace}"`;
189189
}
190-
let argsString: string;
190+
let argsString: string | undefined;
191191
if (shellArgsConfigValue.workspace) {
192192
argsString = `[${shellArgsConfigValue.workspace.map(v => '"' + v + '"').join(', ')}]`;
193193
}
194194
// Should not be localized as it's json-like syntax referencing settings keys
195195
let changeString: string;
196-
if (shellConfigValue.workspace !== undefined) {
197-
if (shellArgsConfigValue.workspace !== undefined) {
196+
if (shellString) {
197+
if (argsString) {
198198
changeString = `shell: ${shellString}, shellArgs: ${argsString}`;
199199
} else {
200200
changeString = `shell: ${shellString}`;
@@ -220,7 +220,7 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
220220
// Change Sysnative to System32 if the OS is Windows but NOT WoW64. It's
221221
// safe to assume that this was used by accident as Sysnative does not
222222
// exist and will break the terminal in non-WoW64 environments.
223-
if (platform.isWindows && !process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432')) {
223+
if (platform.isWindows && !process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432') && process.env.windir) {
224224
const sysnativePath = path.join(process.env.windir, 'Sysnative').toLowerCase();
225225
if (shell.executable.toLowerCase().indexOf(sysnativePath) === 0) {
226226
shell.executable = path.join(process.env.windir, 'System32', shell.executable.substr(sysnativePath.length));

0 commit comments

Comments
 (0)