提交 fe5027c3 编写于 作者: D Daniel Imms

Add tests for TerminalPanel.preparePathForTerminal

Fixes #27771
上级 5a40dc5b
......@@ -246,7 +246,7 @@ export class TerminalPanel extends Panel {
}
const terminal = this._terminalService.getActiveInstance();
terminal.sendText(this._preparePathForTerminal(uri), false);
terminal.sendText(TerminalPanel.preparePathForTerminal(uri), false);
}
}));
}
......@@ -327,7 +327,7 @@ export class TerminalPanel extends Panel {
/**
* Adds quotes to a path if it contains whitespaces
*/
private _preparePathForTerminal(path: string) {
public static preparePathForTerminal(path: string): string {
if (platform.isWindows) {
if (/\s+/.test(path)) {
return `"${path}"`;
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import * as assert from 'assert';
import { TerminalPanel } from 'vs/workbench/parts/terminal/electron-browser/terminalPanel';
import * as platform from 'vs/base/common/platform';
suite('Workbench - TerminalPanel', () => {
test('preparePathForTerminal', function () {
if (platform.isWindows) {
assert.equal(TerminalPanel.preparePathForTerminal('C:\\foo'), 'C:\\foo');
assert.equal(TerminalPanel.preparePathForTerminal('C:\\foo bar'), '"C:\\foo bar"');
return;
}
assert.equal(TerminalPanel.preparePathForTerminal('/a/\\foo bar"\'? ;\'?? :'), '/a/\\\\foo\\ bar\\"\\\'\\?\\ \\;\\\'\\?\\?\\ \\ \\:');
assert.equal(TerminalPanel.preparePathForTerminal('/\\\'"?:;!*(){}[]'), '/\\\\\\\'\\"\\?\\:\\;\\!\\*\\(\\)\\{\\}\\[\\]');
});
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册