File tree Expand file tree Collapse file tree
src/vs/workbench/parts/terminal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -246,7 +246,7 @@ export class TerminalPanel extends Panel {
246246 }
247247
248248 const terminal = this . _terminalService . getActiveInstance ( ) ;
249- terminal . sendText ( this . _preparePathForTerminal ( uri ) , false ) ;
249+ terminal . sendText ( TerminalPanel . preparePathForTerminal ( uri ) , false ) ;
250250 }
251251 } ) ) ;
252252 }
@@ -327,7 +327,7 @@ export class TerminalPanel extends Panel {
327327 /**
328328 * Adds quotes to a path if it contains whitespaces
329329 */
330- private _preparePathForTerminal ( path : string ) {
330+ public static preparePathForTerminal ( path : string ) : string {
331331 if ( platform . isWindows ) {
332332 if ( / \s + / . test ( path ) ) {
333333 return `"${ path } "` ;
Original file line number Diff line number Diff line change 1+ /*---------------------------------------------------------------------------------------------
2+ * Copyright (c) Microsoft Corporation. All rights reserved.
3+ * Licensed under the MIT License. See License.txt in the project root for license information.
4+ *--------------------------------------------------------------------------------------------*/
5+
6+ 'use strict' ;
7+
8+ import * as assert from 'assert' ;
9+ import { TerminalPanel } from 'vs/workbench/parts/terminal/electron-browser/terminalPanel' ;
10+ import * as platform from 'vs/base/common/platform' ;
11+
12+ suite ( 'Workbench - TerminalPanel' , ( ) => {
13+ test ( 'preparePathForTerminal' , function ( ) {
14+ if ( platform . isWindows ) {
15+ assert . equal ( TerminalPanel . preparePathForTerminal ( 'C:\\foo' ) , 'C:\\foo' ) ;
16+ assert . equal ( TerminalPanel . preparePathForTerminal ( 'C:\\foo bar' ) , '"C:\\foo bar"' ) ;
17+ return ;
18+ }
19+ assert . equal ( TerminalPanel . preparePathForTerminal ( '/a/\\foo bar"\'? ;\'?? :' ) , '/a/\\\\foo\\ bar\\"\\\'\\?\\ \\;\\\'\\?\\?\\ \\ \\:' ) ;
20+ assert . equal ( TerminalPanel . preparePathForTerminal ( '/\\\'"?:;!*(){}[]' ) , '/\\\\\\\'\\"\\?\\:\\;\\!\\*\\(\\)\\{\\}\\[\\]' ) ;
21+ } ) ;
22+ } ) ;
You can’t perform that action at this time.
0 commit comments