diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts index 4d4f6645ad04db61e848109ba1d334d7475a5e7a..978e8fe5ea59b65e41e046592d03a09b1d725c45 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts @@ -12,7 +12,7 @@ import { IWorkspaceConfigurationService } from 'vs/workbench/services/configurat 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/parts/terminal/common/terminal'; import Severity from 'vs/base/common/severity'; -import { isFedora } from 'vs/workbench/parts/terminal/node/terminal'; +import { isFedora, isUbuntu } from 'vs/workbench/parts/terminal/node/terminal'; import { Terminal as XTermTerminal } from 'vscode-xterm'; import { INotificationService } from 'vs/platform/notification/common/notification'; @@ -114,15 +114,21 @@ export class TerminalConfigHelper implements ITerminalConfigHelper { const editorConfig = this._configurationService.getValue('editor'); let fontFamily = this.config.fontFamily || editorConfig.fontFamily; + let fontSize = this._toInteger(this.config.fontSize, MINIMUM_FONT_SIZE, MAXIMUM_FONT_SIZE, EDITOR_FONT_DEFAULTS.fontSize); - // Work around bad font on Fedora + // Work around bad font on Fedora/Ubuntu if (!this.config.fontFamily) { if (isFedora) { fontFamily = '\'DejaVu Sans Mono\''; } + if (isUbuntu) { + fontFamily = '\'Ubuntu Mono\''; + + // Ubuntu mono is somehow smaller, so set fontSize a bit larger to get the same perceived size. + fontSize = this._toInteger(fontSize + 2, MINIMUM_FONT_SIZE, MAXIMUM_FONT_SIZE, EDITOR_FONT_DEFAULTS.fontSize); + } } - const fontSize = this._toInteger(this.config.fontSize, MINIMUM_FONT_SIZE, MAXIMUM_FONT_SIZE, EDITOR_FONT_DEFAULTS.fontSize); const letterSpacing = this.config.letterSpacing ? Math.max(Math.floor(this.config.letterSpacing), MINIMUM_LETTER_SPACING) : DEFAULT_LETTER_SPACING; const lineHeight = this.config.lineHeight ? Math.max(this.config.lineHeight, 1) : DEFAULT_LINE_HEIGHT; diff --git a/src/vs/workbench/parts/terminal/node/terminal.ts b/src/vs/workbench/parts/terminal/node/terminal.ts index 7eaadc133aadc7b088bb5ab4b13955fd48d1aba1..be193bf65f47d14967544b4dde895dd5fdaddca4 100644 --- a/src/vs/workbench/parts/terminal/node/terminal.ts +++ b/src/vs/workbench/parts/terminal/node/terminal.ts @@ -65,11 +65,14 @@ if (platform.isLinux) { } readFile(file).then(b => { const contents = b.toString(); - if (contents.indexOf('NAME=Fedora') >= 0) { + if (/NAME="?Fedora"?/.test(contents)) { isFedora = true; + } else if (/NAME="?Ubuntu"?/.test(contents)) { + isUbuntu = true; } }); }); } -export let isFedora = false; \ No newline at end of file +export let isFedora = false; +export let isUbuntu = false; \ No newline at end of file diff --git a/src/vs/workbench/parts/terminal/test/electron-browser/terminalConfigHelper.test.ts b/src/vs/workbench/parts/terminal/test/electron-browser/terminalConfigHelper.test.ts index 27cc89f26cc653bbb099e6fb1795f5e59b7912a3..1cee237241281b7eac26adc32ab4a2fc07084aa9 100644 --- a/src/vs/workbench/parts/terminal/test/electron-browser/terminalConfigHelper.test.ts +++ b/src/vs/workbench/parts/terminal/test/electron-browser/terminalConfigHelper.test.ts @@ -6,7 +6,7 @@ import * as assert from 'assert'; import { TerminalConfigHelper } from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper'; import { EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions'; -import { isFedora } from 'vs/workbench/parts/terminal/node/terminal'; +import { isFedora, isUbuntu } from 'vs/workbench/parts/terminal/node/terminal'; import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; suite('Workbench - TerminalConfigHelper', () => { @@ -32,6 +32,8 @@ suite('Workbench - TerminalConfigHelper', () => { configHelper.panelContainer = fixture; if (isFedora) { assert.equal(configHelper.getFont().fontFamily, '\'DejaVu Sans Mono\'', 'Fedora should have its font overridden when terminal.integrated.fontFamily not set'); + } if (isUbuntu) { + assert.equal(configHelper.getFont().fontFamily, '\'Ubuntu Mono\'', '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'); } @@ -65,8 +67,11 @@ suite('Workbench - TerminalConfigHelper', () => { }); configHelper = new TerminalConfigHelper(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'); - + 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'); + } configurationService.setUserConfiguration('editor', { fontFamily: 'foo' }); @@ -91,7 +96,11 @@ suite('Workbench - TerminalConfigHelper', () => { }); configHelper = new TerminalConfigHelper(configurationService, null, null, null); configHelper.panelContainer = fixture; - assert.equal(configHelper.getFont().fontSize, EDITOR_FONT_DEFAULTS.fontSize, 'The default editor font size should be used when terminal.integrated.fontSize is not set'); + 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'); + } }); test('TerminalConfigHelper - getFont lineHeight', function () {