Skip to content

Commit cb486e9

Browse files
committed
Terminal unicode 11 support
Fixes microsoft#90029
1 parent 24081e0 commit cb486e9

15 files changed

Lines changed: 88 additions & 16 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"vscode-textmate": "4.4.0",
5858
"xterm": "4.4.0",
5959
"xterm-addon-search": "0.4.0",
60+
"xterm-addon-unicode11": "0.1.1",
6061
"xterm-addon-web-links": "0.2.1",
6162
"xterm-addon-webgl": "0.5.0",
6263
"yauzl": "^2.9.2",

remote/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"vscode-textmate": "4.4.0",
2323
"xterm": "4.4.0",
2424
"xterm-addon-search": "0.4.0",
25+
"xterm-addon-unicode11": "0.1.1",
2526
"xterm-addon-web-links": "0.2.1",
2627
"xterm-addon-webgl": "0.5.0",
2728
"yauzl": "^2.9.2",

remote/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"vscode-textmate": "4.4.0",
88
"xterm": "4.4.0",
99
"xterm-addon-search": "0.4.0",
10+
"xterm-addon-unicode11": "0.1.1",
1011
"xterm-addon-web-links": "0.2.1",
1112
"xterm-addon-webgl": "0.5.0"
1213
}

remote/web/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ xterm-addon-search@0.4.0:
3636
resolved "https://registry.yarnpkg.com/xterm-addon-search/-/xterm-addon-search-0.4.0.tgz#a7beadb3caa7330eb31fb1f17d92de25537684a1"
3737
integrity sha512-g07qb/Z4aSfrQ25e6Z6rz6KiExm2DvesQXkx+eA715VABBr5VM/9Jf0INoCiDSYy/nn7rpna+kXiGVJejIffKg==
3838

39+
xterm-addon-unicode11@0.1.1:
40+
version "0.1.1"
41+
resolved "https://registry.yarnpkg.com/xterm-addon-unicode11/-/xterm-addon-unicode11-0.1.1.tgz#b209ef137db38096f68636af4ef4d0c0acba85ad"
42+
integrity sha512-z6vJTL+dpNljwAYzYoyDjJP8A2XjZuEosl0sRa+FGRf3jEyEVWquDM53MfUd1ztVdAPQ839qR6eYK1BXV04Bhw==
43+
3944
xterm-addon-web-links@0.2.1:
4045
version "0.2.1"
4146
resolved "https://registry.yarnpkg.com/xterm-addon-web-links/-/xterm-addon-web-links-0.2.1.tgz#6d1f2ce613e09870badf17615e7a1170a31542b2"

remote/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,11 @@ xterm-addon-search@0.4.0:
418418
resolved "https://registry.yarnpkg.com/xterm-addon-search/-/xterm-addon-search-0.4.0.tgz#a7beadb3caa7330eb31fb1f17d92de25537684a1"
419419
integrity sha512-g07qb/Z4aSfrQ25e6Z6rz6KiExm2DvesQXkx+eA715VABBr5VM/9Jf0INoCiDSYy/nn7rpna+kXiGVJejIffKg==
420420

421+
xterm-addon-unicode11@0.1.1:
422+
version "0.1.1"
423+
resolved "https://registry.yarnpkg.com/xterm-addon-unicode11/-/xterm-addon-unicode11-0.1.1.tgz#b209ef137db38096f68636af4ef4d0c0acba85ad"
424+
integrity sha512-z6vJTL+dpNljwAYzYoyDjJP8A2XjZuEosl0sRa+FGRf3jEyEVWquDM53MfUd1ztVdAPQ839qR6eYK1BXV04Bhw==
425+
421426
xterm-addon-web-links@0.2.1:
422427
version "0.2.1"
423428
resolved "https://registry.yarnpkg.com/xterm-addon-web-links/-/xterm-addon-web-links-0.2.1.tgz#6d1f2ce613e09870badf17615e7a1170a31542b2"

src/vs/code/browser/workbench/workbench-dev.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
'onigasm-umd': `${window.location.origin}/static/remote/web/node_modules/onigasm-umd/release/main`,
3232
'xterm': `${window.location.origin}/static/remote/web/node_modules/xterm/lib/xterm.js`,
3333
'xterm-addon-search': `${window.location.origin}/static/remote/web/node_modules/xterm-addon-search/lib/xterm-addon-search.js`,
34+
'xterm-addon-unicode11': `${window.location.origin}/static/remote/web/node_modules/xterm-addon-unicode11/lib/xterm-addon-unicode11.js`,
3435
'xterm-addon-web-links': `${window.location.origin}/static/remote/web/node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js`,
3536
'xterm-addon-webgl': `${window.location.origin}/static/remote/web/node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js`,
3637
'semver-umd': `${window.location.origin}/static/remote/web/node_modules/semver-umd/lib/semver-umd.js`,

src/vs/code/browser/workbench/workbench.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
'onigasm-umd': `${window.location.origin}/static/node_modules/onigasm-umd/release/main`,
3636
'xterm': `${window.location.origin}/static/node_modules/xterm/lib/xterm.js`,
3737
'xterm-addon-search': `${window.location.origin}/static/node_modules/xterm-addon-search/lib/xterm-addon-search.js`,
38+
'xterm-addon-unicode11': `${window.location.origin}/static/node_modules/xterm-addon-unicode11/lib/xterm-addon-unicode11.js`,
3839
'xterm-addon-web-links': `${window.location.origin}/static/node_modules/xterm-addon-web-links/lib/xterm-addon-web-links.js`,
3940
'xterm-addon-webgl': `${window.location.origin}/static/node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js`,
4041
'semver-umd': `${window.location.origin}/static/node_modules/semver-umd/lib/semver-umd.js`,

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,16 @@ configurationRegistry.registerConfiguration({
343343
description: nls.localize('terminal.integrated.enableFileLinks', "Whether to enable file links in the terminal. Links can be slow when working on a network drive in particular because each file link is verified against the file system."),
344344
type: 'boolean',
345345
default: true
346+
},
347+
'terminal.integrated.unicodeVersion': {
348+
type: 'string',
349+
enum: ['6', '11'],
350+
enumDescriptions: [
351+
nls.localize('terminal.integrated.unicodeVersion.six', "Version 6 of unicode, this is an older version which should work better on older systems."),
352+
nls.localize('terminal.integrated.unicodeVersion.eleven', "Version 11 of unicode, this version provides better support for emoji on modern systems.")
353+
],
354+
default: '11',
355+
description: nls.localize('terminal.integrated.unicodeVersion', "Controls what version of unicode to use when evaluating the width of characters in the terminal. If you experience emoji not taking up the right amount of space or being able to backspace beyond your prompt character then you may want to try tweaking this setting.")
346356
}
347357
}
348358
});

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { Terminal as XTermTerminal } from 'xterm';
7-
import { WebLinksAddon as XTermWebLinksAddon } from 'xterm-addon-web-links';
87
import { SearchAddon as XTermSearchAddon } from 'xterm-addon-search';
8+
import { Unicode11Addon as XTermUnicode11Addon } from 'xterm-addon-unicode11';
9+
import { WebLinksAddon as XTermWebLinksAddon } from 'xterm-addon-web-links';
910
import { WebglAddon as XTermWebglAddon } from 'xterm-addon-webgl';
1011
import { IWindowsShellHelper, ITerminalConfigHelper, ITerminalChildProcess, IShellLaunchConfig, IDefaultShellAndArgsRequest, ISpawnExtHostProcessRequest, IStartExtensionTerminalRequest, IAvailableShellsRequest, ITerminalProcessExtHostProxy, ICommandTracker, INavigationMode, TitleEventSource, ITerminalDimensions } from 'vs/workbench/contrib/terminal/common/terminal';
1112
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
@@ -30,8 +31,9 @@ export interface ITerminalInstanceService {
3031
onRequestDefaultShellAndArgs?: Event<IDefaultShellAndArgsRequest>;
3132

3233
getXtermConstructor(): Promise<typeof XTermTerminal>;
33-
getXtermWebLinksConstructor(): Promise<typeof XTermWebLinksAddon>;
3434
getXtermSearchConstructor(): Promise<typeof XTermSearchAddon>;
35+
getXtermUnicode11Constructor(): Promise<typeof XTermUnicode11Addon>;
36+
getXtermWebLinksConstructor(): Promise<typeof XTermWebLinksAddon>;
3537
getXtermWebglConstructor(): Promise<typeof XTermWebglAddon>;
3638
createWindowsShellHelper(shellProcessId: number, instance: ITerminalInstance, xterm: XTermTerminal): IWindowsShellHelper;
3739
createTerminalProcess(shellLaunchConfig: IShellLaunchConfig, cwd: string, cols: number, rows: number, env: IProcessEnvironment, windowsEnableConpty: boolean): ITerminalChildProcess;

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { ITerminalInstanceService, ITerminalInstance, TerminalShellType } from '
3535
import { TerminalProcessManager } from 'vs/workbench/contrib/terminal/browser/terminalProcessManager';
3636
import { Terminal as XTermTerminal, IBuffer, ITerminalAddon } from 'xterm';
3737
import { SearchAddon, ISearchOptions } from 'xterm-addon-search';
38+
import { Unicode11Addon } from 'xterm-addon-unicode11';
3839
import { CommandTrackerAddon } from 'vs/workbench/contrib/terminal/browser/addons/commandTrackerAddon';
3940
import { NavigationModeAddon } from 'vs/workbench/contrib/terminal/browser/addons/navigationModeAddon';
4041
import { XTermCore } from 'vs/workbench/contrib/terminal/browser/xterm-private';
@@ -200,6 +201,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
200201
private _xterm: XTermTerminal | undefined;
201202
private _xtermCore: XTermCore | undefined;
202203
private _xtermSearch: SearchAddon | undefined;
204+
private _xtermUnicode11: Unicode11Addon | undefined;
203205
private _xtermElement: HTMLDivElement | undefined;
204206
private _terminalHasTextContextKey: IContextKey<boolean>;
205207
private _terminalA11yTreeFocusContextKey: IContextKey<boolean>;
@@ -328,6 +330,9 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
328330
// supported.
329331
this.setVisible(this._isVisible);
330332
}
333+
if (e.affectsConfiguration('terminal.integrated.unicodeVersion')) {
334+
this._updateUnicodeVersion();
335+
}
331336
if (e.affectsConfiguration('editor.accessibilitySupport')) {
332337
this.updateAccessibilitySupport();
333338
}
@@ -484,6 +489,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
484489
});
485490
this._xterm = xterm;
486491
this._xtermCore = (xterm as any)._core as XTermCore;
492+
this._updateUnicodeVersion();
487493
this.updateAccessibilitySupport();
488494
this._terminalInstanceService.getXtermSearchConstructor().then(Addon => {
489495
this._xtermSearch = new Addon();
@@ -1242,6 +1248,18 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
12421248
}
12431249
}
12441250

1251+
private async _updateUnicodeVersion(): Promise<void> {
1252+
if (!this._xterm) {
1253+
throw new Error('Cannot update unicode version before xterm has been initialized');
1254+
}
1255+
if (!this._xtermUnicode11 && this._configHelper.config.unicodeVersion === '11') {
1256+
const Addon = await this._terminalInstanceService.getXtermUnicode11Constructor();
1257+
this._xtermUnicode11 = new Addon();
1258+
this._xterm.loadAddon(this._xtermUnicode11);
1259+
}
1260+
this._xterm.unicode.activeVersion = this._configHelper.config.unicodeVersion;
1261+
}
1262+
12451263
public updateAccessibilitySupport(): void {
12461264
const isEnabled = this._accessibilityService.isScreenReaderOptimized();
12471265
if (isEnabled) {

0 commit comments

Comments
 (0)