Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for TerminalPanel.preparePathForTerminal #30198

Merged
merged 1 commit into from
Jul 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}));
}
Expand Down Expand Up @@ -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}"`;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*---------------------------------------------------------------------------------------------
* 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('/\\\'"?:;!*(){}[]'), '/\\\\\\\'\\"\\?\\:\\;\\!\\*\\(\\)\\{\\}\\[\\]');
});
});