-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
166 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,7 +128,7 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.12.0-beta.24.tgz#5c17256933991856554c95c9bd1eaab42e9727a0" | ||
integrity sha512-+wZxKReEOlfN9JRHyikoffA6Do61/THR7QY35ajkQo0lLutKr6hTd/TLTuZh0PhFVelgTgudpXqlP++Lc0WFIA== | ||
|
||
[email protected].2: | ||
version "4.18.0-beta.2" | ||
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.18.0-beta.2.tgz#50e0de2ebe22fd1600e6d7fbc78136a843bb4c1d" | ||
integrity sha512-fzsSI0xL3HuWBuw5o3xPcR8/R8tTpSd60hHtf0Z2ZrIXDRdniJMw+StOv/xZNp2CUY6LcSiF9MmM0ylgiLHbdw== | ||
[email protected].4: | ||
version "4.18.0-beta.4" | ||
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.18.0-beta.4.tgz#547faa85d8388f6f344d9589dca951177e9ecb23" | ||
integrity sha512-+8uuHuyLTFKVIkRGELJnooR+VkEGBHL+04LXLqXtf8b52W2acUCFq2uL2gTGAIPKbrP14WDiF+dG1m7YctDKTQ== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -928,15 +928,15 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.12.0-beta.24.tgz#5c17256933991856554c95c9bd1eaab42e9727a0" | ||
integrity sha512-+wZxKReEOlfN9JRHyikoffA6Do61/THR7QY35ajkQo0lLutKr6hTd/TLTuZh0PhFVelgTgudpXqlP++Lc0WFIA== | ||
|
||
[email protected].2: | ||
version "4.18.0-beta.2" | ||
resolved "https://registry.yarnpkg.com/xterm-headless/-/xterm-headless-4.18.0-beta.2.tgz#b930ac8a79626ef4443cd3ab1a86d1a96039fef8" | ||
integrity sha512-V4CSLfjqE1/pV+3HEs8l0T5W3FORoVX2f17AIUTSsuXUunNXcpib+g6ExxnR9Nm5ztbYnmZIX8AA3mClpqO1OQ== | ||
|
||
[email protected].2: | ||
version "4.18.0-beta.2" | ||
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.18.0-beta.2.tgz#50e0de2ebe22fd1600e6d7fbc78136a843bb4c1d" | ||
integrity sha512-fzsSI0xL3HuWBuw5o3xPcR8/R8tTpSd60hHtf0Z2ZrIXDRdniJMw+StOv/xZNp2CUY6LcSiF9MmM0ylgiLHbdw== | ||
[email protected].4: | ||
version "4.18.0-beta.4" | ||
resolved "https://registry.yarnpkg.com/xterm-headless/-/xterm-headless-4.18.0-beta.4.tgz#6083fdbcf6357756be0f21336cb99dae6fc81ed1" | ||
integrity sha512-0wOzTHltRBZxYjvAGTsFthNS08hEZBdxDPnFMRSP3RgPEwUB/6nlK2q4/RKyWkLYm4XPuKKk8lrSE43awm/7WA== | ||
|
||
[email protected].4: | ||
version "4.18.0-beta.4" | ||
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.18.0-beta.4.tgz#547faa85d8388f6f344d9589dca951177e9ecb23" | ||
integrity sha512-+8uuHuyLTFKVIkRGELJnooR+VkEGBHL+04LXLqXtf8b52W2acUCFq2uL2gTGAIPKbrP14WDiF+dG1m7YctDKTQ== | ||
|
||
yauzl@^2.9.2: | ||
version "2.10.0" | ||
|
139 changes: 139 additions & 0 deletions
139
src/vs/workbench/contrib/terminal/test/browser/xterm/decorationAddon.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { Terminal } from 'xterm'; | ||
import { strictEqual } from 'assert'; | ||
import { timeout } from 'vs/base/common/async'; | ||
import * as sinon from 'sinon'; | ||
import { ShellIntegrationAddon } from 'vs/workbench/contrib/terminal/browser/xterm/shellIntegrationAddon'; | ||
import { ITerminalCapabilityStore, TerminalCapability } from 'vs/workbench/contrib/terminal/common/capabilities/capabilities'; | ||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock'; | ||
import { ILogService, NullLogService } from 'vs/platform/log/common/log'; | ||
|
||
async function writeP(terminal: Terminal, data: string): Promise<void> { | ||
return new Promise<void>((resolve, reject) => { | ||
const failTimeout = timeout(2000); | ||
failTimeout.then(() => reject('Writing to xterm is taking longer than 2 seconds')); | ||
terminal.write(data, () => { | ||
failTimeout.cancel(); | ||
resolve(); | ||
}); | ||
}); | ||
} | ||
|
||
class TestShellIntegrationAddon extends ShellIntegrationAddon { | ||
getCommandDetectionMock(terminal: Terminal): sinon.SinonMock { | ||
const capability = super._createOrGetCommandDetection(terminal); | ||
this.capabilities.add(TerminalCapability.CommandDetection, capability); | ||
return sinon.mock(capability); | ||
} | ||
getCwdDectionMock(): sinon.SinonMock { | ||
const capability = super._createOrGetCwdDetection(); | ||
this.capabilities.add(TerminalCapability.CwdDetection, capability); | ||
return sinon.mock(capability); | ||
} | ||
} | ||
|
||
suite('DecorationAddon', () => { | ||
let xterm: Terminal; | ||
let shellIntegrationAddon: TestShellIntegrationAddon; | ||
let capabilities: ITerminalCapabilityStore; | ||
|
||
setup(() => { | ||
xterm = new Terminal({ | ||
cols: 80, | ||
rows: 30 | ||
}); | ||
const instantiationService = new TestInstantiationService(); | ||
instantiationService.stub(ILogService, NullLogService); | ||
shellIntegrationAddon = instantiationService.createInstance(TestShellIntegrationAddon); | ||
xterm.loadAddon(shellIntegrationAddon); | ||
capabilities = shellIntegrationAddon.capabilities; | ||
}); | ||
|
||
suite('cwd detection', async () => { | ||
test('should activate capability on the cwd sequence (OSC 1337 ; CurrentDir=<cwd> ST)', async () => { | ||
strictEqual(capabilities.has(TerminalCapability.CwdDetection), false); | ||
await writeP(xterm, 'foo'); | ||
strictEqual(capabilities.has(TerminalCapability.CwdDetection), false); | ||
await writeP(xterm, '\x1b]1337;CurrentDir=/foo\x07'); | ||
strictEqual(capabilities.has(TerminalCapability.CwdDetection), true); | ||
}); | ||
test('should pass cwd sequence to the capability', async () => { | ||
const mock = shellIntegrationAddon.getCwdDectionMock(); | ||
mock.expects('updateCwd').once().withExactArgs('/foo'); | ||
await writeP(xterm, '\x1b]1337;CurrentDir=/foo\x07'); | ||
mock.verify(); | ||
}); | ||
}); | ||
|
||
suite('command tracking', async () => { | ||
test('should activate capability on the prompt start sequence (OSC 133 ; A ST)', async () => { | ||
strictEqual(capabilities.has(TerminalCapability.CommandDetection), false); | ||
await writeP(xterm, 'foo'); | ||
strictEqual(capabilities.has(TerminalCapability.CommandDetection), false); | ||
await writeP(xterm, '\x1b]133;A\x07'); | ||
strictEqual(capabilities.has(TerminalCapability.CommandDetection), true); | ||
}); | ||
test('should pass prompt start sequence to the capability', async () => { | ||
const mock = shellIntegrationAddon.getCommandDetectionMock(xterm); | ||
mock.expects('handlePromptStart').once().withExactArgs(); | ||
await writeP(xterm, '\x1b]133;A\x07'); | ||
mock.verify(); | ||
}); | ||
test('should activate capability on the command start sequence (OSC 133 ; B ST)', async () => { | ||
strictEqual(capabilities.has(TerminalCapability.CommandDetection), false); | ||
await writeP(xterm, 'foo'); | ||
strictEqual(capabilities.has(TerminalCapability.CommandDetection), false); | ||
await writeP(xterm, '\x1b]133;B\x07'); | ||
strictEqual(capabilities.has(TerminalCapability.CommandDetection), true); | ||
}); | ||
test('should pass command start sequence to the capability', async () => { | ||
const mock = shellIntegrationAddon.getCommandDetectionMock(xterm); | ||
mock.expects('handleCommandStart').once().withExactArgs(); | ||
await writeP(xterm, '\x1b]133;B\x07'); | ||
mock.verify(); | ||
}); | ||
test('should activate capability on the command executed sequence (OSC 133 ; C ST)', async () => { | ||
strictEqual(capabilities.has(TerminalCapability.CommandDetection), false); | ||
await writeP(xterm, 'foo'); | ||
strictEqual(capabilities.has(TerminalCapability.CommandDetection), false); | ||
await writeP(xterm, '\x1b]133;C\x07'); | ||
strictEqual(capabilities.has(TerminalCapability.CommandDetection), true); | ||
}); | ||
test('should pass command executed sequence to the capability', async () => { | ||
const mock = shellIntegrationAddon.getCommandDetectionMock(xterm); | ||
mock.expects('handleCommandExecuted').once().withExactArgs(); | ||
await writeP(xterm, '\x1b]133;C\x07'); | ||
mock.verify(); | ||
}); | ||
test('should activate capability on the command finished sequence (OSC 133 ; D ; <ExitCode> ST)', async () => { | ||
strictEqual(capabilities.has(TerminalCapability.CommandDetection), false); | ||
await writeP(xterm, 'foo'); | ||
strictEqual(capabilities.has(TerminalCapability.CommandDetection), false); | ||
await writeP(xterm, '\x1b]133;D;7\x07'); | ||
strictEqual(capabilities.has(TerminalCapability.CommandDetection), true); | ||
}); | ||
test('should pass command finished sequence to the capability', async () => { | ||
const mock = shellIntegrationAddon.getCommandDetectionMock(xterm); | ||
mock.expects('handleCommandFinished').once().withExactArgs(7); | ||
await writeP(xterm, '\x1b]133;D;7\x07'); | ||
mock.verify(); | ||
}); | ||
test('should not activate capability on the cwd sequence (OSC 1337 ; CurrentDir=<cwd> ST)', async () => { | ||
strictEqual(capabilities.has(TerminalCapability.CommandDetection), false); | ||
await writeP(xterm, 'foo'); | ||
strictEqual(capabilities.has(TerminalCapability.CommandDetection), false); | ||
await writeP(xterm, '\x1b]1337;CurrentDir=/foo\x07'); | ||
strictEqual(capabilities.has(TerminalCapability.CommandDetection), false); | ||
}); | ||
test('should pass cwd sequence to the capability if it\'s initialized', async () => { | ||
const mock = shellIntegrationAddon.getCommandDetectionMock(xterm); | ||
mock.expects('setCwd').once().withExactArgs('/foo'); | ||
await writeP(xterm, '\x1b]1337;CurrentDir=/foo\x07'); | ||
mock.verify(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12368,15 +12368,15 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/xterm-addon-webgl/-/xterm-addon-webgl-0.12.0-beta.24.tgz#5c17256933991856554c95c9bd1eaab42e9727a0" | ||
integrity sha512-+wZxKReEOlfN9JRHyikoffA6Do61/THR7QY35ajkQo0lLutKr6hTd/TLTuZh0PhFVelgTgudpXqlP++Lc0WFIA== | ||
|
||
[email protected].2: | ||
version "4.18.0-beta.2" | ||
resolved "https://registry.yarnpkg.com/xterm-headless/-/xterm-headless-4.18.0-beta.2.tgz#b930ac8a79626ef4443cd3ab1a86d1a96039fef8" | ||
integrity sha512-V4CSLfjqE1/pV+3HEs8l0T5W3FORoVX2f17AIUTSsuXUunNXcpib+g6ExxnR9Nm5ztbYnmZIX8AA3mClpqO1OQ== | ||
|
||
[email protected].2: | ||
version "4.18.0-beta.2" | ||
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.18.0-beta.2.tgz#50e0de2ebe22fd1600e6d7fbc78136a843bb4c1d" | ||
integrity sha512-fzsSI0xL3HuWBuw5o3xPcR8/R8tTpSd60hHtf0Z2ZrIXDRdniJMw+StOv/xZNp2CUY6LcSiF9MmM0ylgiLHbdw== | ||
[email protected].4: | ||
version "4.18.0-beta.4" | ||
resolved "https://registry.yarnpkg.com/xterm-headless/-/xterm-headless-4.18.0-beta.4.tgz#6083fdbcf6357756be0f21336cb99dae6fc81ed1" | ||
integrity sha512-0wOzTHltRBZxYjvAGTsFthNS08hEZBdxDPnFMRSP3RgPEwUB/6nlK2q4/RKyWkLYm4XPuKKk8lrSE43awm/7WA== | ||
|
||
[email protected].4: | ||
version "4.18.0-beta.4" | ||
resolved "https://registry.yarnpkg.com/xterm/-/xterm-4.18.0-beta.4.tgz#547faa85d8388f6f344d9589dca951177e9ecb23" | ||
integrity sha512-+8uuHuyLTFKVIkRGELJnooR+VkEGBHL+04LXLqXtf8b52W2acUCFq2uL2gTGAIPKbrP14WDiF+dG1m7YctDKTQ== | ||
|
||
y18n@^3.2.1: | ||
version "3.2.2" | ||
|