提交 1d1dbdc4 编写于 作者: D Daniel Imms

Move TerminalConfigHelper, electron-browser->browser

Part of #69115
上级 2675ffea
......@@ -279,6 +279,7 @@
"./vs/workbench/contrib/surveys/electron-browser/nps.contribution.ts",
"./vs/workbench/contrib/terminal/browser/terminalActions.ts",
"./vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts",
"./vs/workbench/contrib/terminal/browser/terminalFindWidget.ts",
"./vs/workbench/contrib/terminal/browser/terminalLinkHandler.ts",
"./vs/workbench/contrib/terminal/browser/terminalPanel.ts",
......@@ -291,7 +292,6 @@
"./vs/workbench/contrib/terminal/common/terminalEnvironment.ts",
"./vs/workbench/contrib/terminal/common/terminalMenu.ts",
"./vs/workbench/contrib/terminal/common/terminalService.ts",
"./vs/workbench/contrib/terminal/electron-browser/terminalConfigHelper.ts",
"./vs/workbench/contrib/terminal/electron-browser/terminalInstance.ts",
"./vs/workbench/contrib/terminal/electron-browser/terminalProcessManager.ts",
"./vs/workbench/contrib/terminal/node/terminal.ts",
......
......@@ -10,9 +10,8 @@ import { EDITOR_FONT_DEFAULTS, IEditorOptions } from 'vs/editor/common/config/ed
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { ITerminalConfiguration, ITerminalConfigHelper, ITerminalFont, IShellLaunchConfig, IS_WORKSPACE_SHELL_ALLOWED_STORAGE_KEY, TERMINAL_CONFIG_SECTION, DEFAULT_LETTER_SPACING, DEFAULT_LINE_HEIGHT, MINIMUM_LETTER_SPACING } from 'vs/workbench/contrib/terminal/common/terminal';
import { ITerminalConfiguration, ITerminalConfigHelper, ITerminalFont, IShellLaunchConfig, IS_WORKSPACE_SHELL_ALLOWED_STORAGE_KEY, TERMINAL_CONFIG_SECTION, DEFAULT_LETTER_SPACING, DEFAULT_LINE_HEIGHT, MINIMUM_LETTER_SPACING, LinuxDistro } from 'vs/workbench/contrib/terminal/common/terminal';
import Severity from 'vs/base/common/severity';
import { isFedora, isUbuntu } from 'vs/workbench/contrib/terminal/node/terminal';
import { Terminal as XTermTerminal } from 'vscode-xterm';
import { INotificationService } from 'vs/platform/notification/common/notification';
......@@ -31,6 +30,7 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
public config: ITerminalConfiguration;
public constructor(
private readonly _linuxDistro: LinuxDistro,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@IWorkspaceConfigurationService private readonly _workspaceConfigurationService: IWorkspaceConfigurationService,
@INotificationService private readonly _notificationService: INotificationService,
......@@ -118,10 +118,10 @@ export class TerminalConfigHelper implements ITerminalConfigHelper {
// Work around bad font on Fedora/Ubuntu
if (!this.config.fontFamily) {
if (isFedora) {
if (this._linuxDistro === LinuxDistro.Fedora) {
fontFamily = '\'DejaVu Sans Mono\', monospace';
}
if (isUbuntu) {
if (this._linuxDistro === LinuxDistro.Ubuntu) {
fontFamily = '\'Ubuntu Mono\', monospace';
// Ubuntu mono is somehow smaller, so set fontSize a bit larger to get the same perceived size.
......
......@@ -687,4 +687,10 @@ export interface ITerminalProcessExtHostRequest {
activeWorkspaceRootUri: URI;
cols: number;
rows: number;
}
export enum LinuxDistro {
Fedora,
Ubuntu,
Unknown
}
\ No newline at end of file
......@@ -23,7 +23,7 @@ export abstract class TerminalService implements ITerminalService {
protected _terminalFocusContextKey: IContextKey<boolean>;
protected _findWidgetVisible: IContextKey<boolean>;
protected _terminalContainer: HTMLElement;
protected _terminalTabs: ITerminalTab[];
protected _terminalTabs: ITerminalTab[] = [];
protected get _terminalInstances(): ITerminalInstance[] {
return this._terminalTabs.reduce((p, c) => p.concat(c.terminalInstances), <ITerminalInstance[]>[]);
}
......
......@@ -30,7 +30,7 @@ import { TerminalWidgetManager } from 'vs/workbench/contrib/terminal/browser/ter
import { IShellLaunchConfig, ITerminalDimensions, ITerminalInstance, ITerminalProcessManager, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, NEVER_MEASURE_RENDER_TIME_STORAGE_KEY, ProcessState, TERMINAL_PANEL_ID } from 'vs/workbench/contrib/terminal/common/terminal';
import { ansiColorIdentifiers, TERMINAL_BACKGROUND_COLOR, TERMINAL_CURSOR_BACKGROUND_COLOR, TERMINAL_CURSOR_FOREGROUND_COLOR, TERMINAL_FOREGROUND_COLOR, TERMINAL_SELECTION_BACKGROUND_COLOR } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry';
import { TERMINAL_COMMAND_ID } from 'vs/workbench/contrib/terminal/common/terminalCommands';
import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/electron-browser/terminalConfigHelper';
import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/terminalConfigHelper';
import { TerminalLinkHandler } from 'vs/workbench/contrib/terminal/browser/terminalLinkHandler';
import { TerminalProcessManager } from 'vs/workbench/contrib/terminal/electron-browser/terminalProcessManager';
import { TerminalCommandTracker } from 'vs/workbench/contrib/terminal/node/terminalCommandTracker';
......
......@@ -14,10 +14,10 @@ import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { ITerminalInstance, ITerminalService, IShellLaunchConfig, ITerminalConfigHelper, NEVER_SUGGEST_SELECT_WINDOWS_SHELL_STORAGE_KEY, ITerminalProcessExtHostProxy } from 'vs/workbench/contrib/terminal/common/terminal';
import { TerminalService as BrowserTerminalService } from 'vs/workbench/contrib/terminal/browser/terminalService';
import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/electron-browser/terminalConfigHelper';
import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/terminalConfigHelper';
import Severity from 'vs/base/common/severity';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { getDefaultShell } from 'vs/workbench/contrib/terminal/node/terminal';
import { getDefaultShell, linuxDistro } from 'vs/workbench/contrib/terminal/node/terminal';
import { TerminalTab } from 'vs/workbench/contrib/terminal/browser/terminalTab';
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { INotificationService } from 'vs/platform/notification/common/notification';
......@@ -49,8 +49,7 @@ export class TerminalService extends BrowserTerminalService implements ITerminal
) {
super(contextKeyService, panelService, partService, lifecycleService, storageService, notificationService, dialogService);
this._terminalTabs = [];
this._configHelper = this._instantiationService.createInstance(TerminalConfigHelper);
this._configHelper = this._instantiationService.createInstance(TerminalConfigHelper, linuxDistro);
ipc.on('vscode:openFiles', (_event: any, request: IOpenFileRequest) => {
// if the request to open files is coming in from the integrated terminal (identified though
// the termProgram variable) and we are instructed to wait for editors close, wait for the
......
......@@ -8,6 +8,7 @@ import * as platform from 'vs/base/common/platform';
import * as processes from 'vs/base/node/processes';
import { readFile, fileExists } from 'vs/base/node/pfs';
import { Event } from 'vs/base/common/event';
import { LinuxDistro } from 'vs/workbench/contrib/terminal/common/terminal';
/**
* An interface representing a raw terminal child process, this contains a subset of the
......@@ -78,6 +79,7 @@ function getTerminalDefaultShellWindows(): string {
return _TERMINAL_DEFAULT_SHELL_WINDOWS;
}
let detectedDistro = LinuxDistro.Unknown;
if (platform.isLinux) {
const file = '/etc/os-release';
fileExists(file).then(exists => {
......@@ -87,13 +89,12 @@ if (platform.isLinux) {
readFile(file).then(b => {
const contents = b.toString();
if (/NAME="?Fedora"?/.test(contents)) {
isFedora = true;
detectedDistro = LinuxDistro.Fedora;
} else if (/NAME="?Ubuntu"?/.test(contents)) {
isUbuntu = true;
detectedDistro = LinuxDistro.Ubuntu;
}
});
});
}
export let isFedora = false;
export let isUbuntu = false;
\ No newline at end of file
export const linuxDistro = detectedDistro;
......@@ -4,10 +4,10 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/electron-browser/terminalConfigHelper';
import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/terminalConfigHelper';
import { EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions';
import { isFedora, isUbuntu } from 'vs/workbench/contrib/terminal/node/terminal';
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { LinuxDistro } from 'vs/workbench/contrib/terminal/common/terminal';
suite('Workbench - TerminalConfigHelper', () => {
let fixture: HTMLElement;
......@@ -21,22 +21,24 @@ suite('Workbench - TerminalConfigHelper', () => {
configurationService.setUserConfiguration('editor', { fontFamily: 'foo' });
configurationService.setUserConfiguration('terminal', { integrated: { fontFamily: 'bar' } });
let configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!);
let configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
assert.equal(configHelper.getFont().fontFamily, 'bar', 'terminal.integrated.fontFamily should be selected over editor.fontFamily');
configurationService.setUserConfiguration('terminal', { integrated: { fontFamily: null } });
// Recreate config helper as onDidChangeConfiguration isn't implemented in TestConfigurationService
configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
if (isFedora) {
assert.equal(configHelper.getFont().fontFamily, '\'DejaVu Sans Mono\', monospace', 'Fedora should have its font overridden when terminal.integrated.fontFamily not set');
} else if (isUbuntu) {
assert.equal(configHelper.getFont().fontFamily, '\'Ubuntu Mono\', monospace', 'Ubuntu should have its font overridden when terminal.integrated.fontFamily not set');
} else {
assert.equal(configHelper.getFont().fontFamily, 'foo', 'editor.fontFamily should be the fallback when terminal.integrated.fontFamily not set');
}
configHelper = new TerminalConfigHelper(LinuxDistro.Fedora, configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
assert.equal(configHelper.getFont().fontFamily, '\'DejaVu Sans Mono\', monospace', 'Fedora should have its font overridden when terminal.integrated.fontFamily not set');
configHelper = new TerminalConfigHelper(LinuxDistro.Ubuntu, configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
assert.equal(configHelper.getFont().fontFamily, '\'Ubuntu Mono\', monospace', 'Ubuntu should have its font overridden when terminal.integrated.fontFamily not set');
configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
assert.equal(configHelper.getFont().fontFamily, 'foo', 'editor.fontFamily should be the fallback when terminal.integrated.fontFamily not set');
});
test('TerminalConfigHelper - getFont fontSize', function () {
......@@ -52,7 +54,7 @@ suite('Workbench - TerminalConfigHelper', () => {
fontSize: 10
}
});
let configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!);
let configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
assert.equal(configHelper.getFont().fontSize, 10, 'terminal.integrated.fontSize should be selected over editor.fontSize');
......@@ -65,13 +67,14 @@ suite('Workbench - TerminalConfigHelper', () => {
fontSize: 0
}
});
configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!);
configHelper = new TerminalConfigHelper(LinuxDistro.Ubuntu, configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
if (isUbuntu) {
assert.equal(configHelper.getFont().fontSize, 8, 'The minimum terminal font size (with adjustment) should be used when terminal.integrated.fontSize less than it');
} else {
assert.equal(configHelper.getFont().fontSize, 6, 'The minimum terminal font size should be used when terminal.integrated.fontSize less than it');
}
assert.equal(configHelper.getFont().fontSize, 8, 'The minimum terminal font size (with adjustment) should be used when terminal.integrated.fontSize less than it');
configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
assert.equal(configHelper.getFont().fontSize, 6, 'The minimum terminal font size should be used when terminal.integrated.fontSize less than it');
configurationService.setUserConfiguration('editor', {
fontFamily: 'foo'
});
......@@ -81,7 +84,7 @@ suite('Workbench - TerminalConfigHelper', () => {
fontSize: 1500
}
});
configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!);
configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
assert.equal(configHelper.getFont().fontSize, 25, 'The maximum terminal font size should be used when terminal.integrated.fontSize more than it');
......@@ -94,13 +97,13 @@ suite('Workbench - TerminalConfigHelper', () => {
fontSize: null
}
});
configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!);
configHelper = new TerminalConfigHelper(LinuxDistro.Ubuntu, configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
assert.equal(configHelper.getFont().fontSize, EDITOR_FONT_DEFAULTS.fontSize + 2, 'The default editor font size (with adjustment) should be used when terminal.integrated.fontSize is not set');
configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
if (isUbuntu) {
assert.equal(configHelper.getFont().fontSize, EDITOR_FONT_DEFAULTS.fontSize + 2, 'The default editor font size (with adjustment) should be used when terminal.integrated.fontSize is not set');
} else {
assert.equal(configHelper.getFont().fontSize, EDITOR_FONT_DEFAULTS.fontSize, 'The default editor font size should be used when terminal.integrated.fontSize is not set');
}
assert.equal(configHelper.getFont().fontSize, EDITOR_FONT_DEFAULTS.fontSize, 'The default editor font size should be used when terminal.integrated.fontSize is not set');
});
test('TerminalConfigHelper - getFont lineHeight', function () {
......@@ -116,7 +119,7 @@ suite('Workbench - TerminalConfigHelper', () => {
lineHeight: 2
}
});
let configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!);
let configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
assert.equal(configHelper.getFont().lineHeight, 2, 'terminal.integrated.lineHeight should be selected over editor.lineHeight');
......@@ -130,7 +133,7 @@ suite('Workbench - TerminalConfigHelper', () => {
lineHeight: 0
}
});
configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!);
configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
assert.equal(configHelper.getFont().lineHeight, 1, 'editor.lineHeight should be 1 when terminal.integrated.lineHeight not set');
});
......@@ -143,7 +146,7 @@ suite('Workbench - TerminalConfigHelper', () => {
}
});
let configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!);
let configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
assert.equal(configHelper.configFontIsMonospace(), true, 'monospace is monospaced');
});
......@@ -155,7 +158,7 @@ suite('Workbench - TerminalConfigHelper', () => {
fontFamily: 'sans-serif'
}
});
let configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!);
let configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
assert.equal(configHelper.configFontIsMonospace(), false, 'sans-serif is not monospaced');
});
......@@ -167,7 +170,7 @@ suite('Workbench - TerminalConfigHelper', () => {
fontFamily: 'serif'
}
});
let configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!);
let configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
assert.equal(configHelper.configFontIsMonospace(), false, 'serif is not monospaced');
});
......@@ -183,7 +186,7 @@ suite('Workbench - TerminalConfigHelper', () => {
}
});
let configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!);
let configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
assert.equal(configHelper.configFontIsMonospace(), true, 'monospace is monospaced');
});
......@@ -199,7 +202,7 @@ suite('Workbench - TerminalConfigHelper', () => {
}
});
let configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!);
let configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
assert.equal(configHelper.configFontIsMonospace(), false, 'sans-serif is not monospaced');
});
......@@ -215,7 +218,7 @@ suite('Workbench - TerminalConfigHelper', () => {
}
});
let configHelper = new TerminalConfigHelper(configurationService, null!, null!, null!);
let configHelper = new TerminalConfigHelper(LinuxDistro.Unknown, configurationService, null!, null!, null!);
configHelper.panelContainer = fixture;
assert.equal(configHelper.configFontIsMonospace(), false, 'serif is not monospaced');
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册