Skip to content

Commit e3a3c3a

Browse files
committed
Tidy up terminal code
Consistently prefix private members with _ to be consistent with ext code and prevent possible errors with not using correct event handler member.
1 parent 5ba13dd commit e3a3c3a

5 files changed

Lines changed: 261 additions & 249 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,12 @@ export class SwitchTerminalInstanceActionItem extends SelectActionItem {
238238
@ITerminalService private terminalService: ITerminalService
239239
) {
240240
super(null, action, terminalService.getInstanceLabels(), terminalService.activeTerminalInstanceIndex);
241-
this.toDispose.push(terminalService.onInstancesChanged(this.updateItems, this));
242-
this.toDispose.push(terminalService.onActiveInstanceChanged(this.updateItems, this));
243-
this.toDispose.push(terminalService.onInstanceTitleChanged(this.updateItems, this));
241+
this.toDispose.push(terminalService.onInstancesChanged(this._updateItems, this));
242+
this.toDispose.push(terminalService.onActiveInstanceChanged(this._updateItems, this));
243+
this.toDispose.push(terminalService.onInstanceTitleChanged(this._updateItems, this));
244244
}
245245

246-
private updateItems(): void {
246+
private _updateItems(): void {
247247
this.setOptions(this.terminalService.getInstanceLabels(), this.terminalService.activeTerminalInstanceIndex);
248248
}
249249
}

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,29 +89,29 @@ export interface IShell {
8989
export class TerminalConfigHelper {
9090
public panelContainer: Builder;
9191

92-
private charMeasureElement: HTMLElement;
92+
private _charMeasureElement: HTMLElement;
9393

9494
public constructor(
95-
private platform: Platform,
96-
@IConfigurationService private configurationService: IConfigurationService) {
95+
private _platform: Platform,
96+
@IConfigurationService private _configurationService: IConfigurationService) {
9797
}
9898

9999
public getTheme(baseThemeId: string): string[] {
100100
return DEFAULT_ANSI_COLORS[baseThemeId];
101101
}
102102

103-
private measureFont(fontFamily: string, fontSize: number, lineHeight: number): ITerminalFont {
103+
private _measureFont(fontFamily: string, fontSize: number, lineHeight: number): ITerminalFont {
104104
// Create charMeasureElement if it hasn't been created or if it was orphaned by its parent
105-
if (!this.charMeasureElement || !this.charMeasureElement.parentElement) {
106-
this.charMeasureElement = this.panelContainer.div().getHTMLElement();
105+
if (!this._charMeasureElement || !this._charMeasureElement.parentElement) {
106+
this._charMeasureElement = this.panelContainer.div().getHTMLElement();
107107
}
108-
let style = this.charMeasureElement.style;
108+
let style = this._charMeasureElement.style;
109109
style.display = 'block';
110110
style.fontFamily = fontFamily;
111111
style.fontSize = fontSize + 'px';
112112
style.height = Math.floor(lineHeight * fontSize) + 'px';
113-
this.charMeasureElement.innerText = 'X';
114-
let rect = this.charMeasureElement.getBoundingClientRect();
113+
this._charMeasureElement.innerText = 'X';
114+
let rect = this._charMeasureElement.getBoundingClientRect();
115115
style.display = 'none';
116116
let charWidth = Math.ceil(rect.width);
117117
let charHeight = Math.ceil(rect.height);
@@ -129,8 +129,8 @@ export class TerminalConfigHelper {
129129
* terminal.integrated.fontSize, terminal.integrated.lineHeight configuration properties
130130
*/
131131
public getFont(): ITerminalFont {
132-
let terminalConfig = this.configurationService.getConfiguration<ITerminalConfiguration>().terminal.integrated;
133-
let editorConfig = this.configurationService.getConfiguration<IConfiguration>();
132+
let terminalConfig = this._configurationService.getConfiguration<ITerminalConfiguration>().terminal.integrated;
133+
let editorConfig = this._configurationService.getConfiguration<IConfiguration>();
134134

135135
let fontFamily = terminalConfig.fontFamily || editorConfig.editor.fontFamily;
136136
let fontSize = this.toInteger(terminalConfig.fontSize, 0) || editorConfig.editor.fontSize;
@@ -139,39 +139,39 @@ export class TerminalConfigHelper {
139139
}
140140
let lineHeight = this.toInteger(terminalConfig.lineHeight, DEFAULT_LINE_HEIGHT);
141141

142-
return this.measureFont(fontFamily, fontSize, lineHeight <= 0 ? DEFAULT_LINE_HEIGHT : lineHeight);
142+
return this._measureFont(fontFamily, fontSize, lineHeight <= 0 ? DEFAULT_LINE_HEIGHT : lineHeight);
143143
}
144144

145145
public getFontLigaturesEnabled(): boolean {
146-
let terminalConfig = this.configurationService.getConfiguration<ITerminalConfiguration>().terminal.integrated;
146+
let terminalConfig = this._configurationService.getConfiguration<ITerminalConfiguration>().terminal.integrated;
147147
return terminalConfig.fontLigatures;
148148
}
149149

150150
public getCursorBlink(): boolean {
151-
let terminalConfig = this.configurationService.getConfiguration<ITerminalConfiguration>().terminal.integrated;
151+
let terminalConfig = this._configurationService.getConfiguration<ITerminalConfiguration>().terminal.integrated;
152152
return terminalConfig.cursorBlinking;
153153
}
154154

155155
public getShell(): IShell {
156-
let config = this.configurationService.getConfiguration<ITerminalConfiguration>();
156+
let config = this._configurationService.getConfiguration<ITerminalConfiguration>();
157157
let shell: IShell = {
158158
executable: '',
159159
args: []
160160
};
161-
if (this.platform === Platform.Windows) {
161+
if (this._platform === Platform.Windows) {
162162
shell.executable = config.terminal.integrated.shell.windows;
163-
} else if (this.platform === Platform.Mac) {
163+
} else if (this._platform === Platform.Mac) {
164164
shell.executable = config.terminal.integrated.shell.osx;
165165
shell.args = config.terminal.integrated.shellArgs.osx;
166-
} else if (this.platform === Platform.Linux) {
166+
} else if (this._platform === Platform.Linux) {
167167
shell.executable = config.terminal.integrated.shell.linux;
168168
shell.args = config.terminal.integrated.shellArgs.linux;
169169
}
170170
return shell;
171171
}
172172

173173
public isSetLocaleVariables(): boolean {
174-
let config = this.configurationService.getConfiguration<ITerminalConfiguration>();
174+
let config = this._configurationService.getConfiguration<ITerminalConfiguration>();
175175
return config.terminal.integrated.setLocaleVariables;
176176
}
177177

@@ -187,7 +187,7 @@ export class TerminalConfigHelper {
187187
}
188188

189189
public getCommandsToSkipShell(): string[] {
190-
let config = this.configurationService.getConfiguration<ITerminalConfiguration>();
190+
let config = this._configurationService.getConfiguration<ITerminalConfiguration>();
191191
return config.terminal.integrated.commandsToSkipShell;
192192
}
193193
}

0 commit comments

Comments
 (0)