Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
01b1d00a
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
01b1d00a
编写于
10月 22, 2016
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix cmder external terminal initial cwd
Fixes #6466
上级
9ce81913
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
51 addition
and
4 deletion
+51
-4
src/vs/workbench/parts/execution/electron-browser/terminalService.ts
...bench/parts/execution/electron-browser/terminalService.ts
+26
-3
src/vs/workbench/parts/execution/test/electron-browser/terminalService.test.ts
...s/execution/test/electron-browser/terminalService.test.ts
+25
-1
未找到文件。
src/vs/workbench/parts/execution/electron-browser/terminalService.ts
浏览文件 @
01b1d00a
...
...
@@ -6,6 +6,7 @@
'
use strict
'
;
import
cp
=
require
(
'
child_process
'
);
import
path
=
require
(
'
path
'
);
import
processes
=
require
(
'
vs/base/node/processes
'
);
import
nls
=
require
(
'
vs/nls
'
);
import
errors
=
require
(
'
vs/base/common/errors
'
);
...
...
@@ -18,6 +19,11 @@ import { IProcessEnvironment } from 'vs/base/common/platform';
const
TERMINAL_TITLE
=
nls
.
localize
(
'
console.title
'
,
"
VS Code Console
"
);
enum
WinSpawnType
{
CMD
,
CMDER
}
export
class
WinTerminalService
implements
ITerminalService
{
public
_serviceBrand
:
any
;
...
...
@@ -69,15 +75,24 @@ export class WinTerminalService implements ITerminalService {
private
spawnTerminal
(
spawner
,
configuration
:
ITerminalConfiguration
,
command
:
string
,
path
?:
string
):
TPromise
<
void
>
{
let
terminalConfig
=
configuration
.
terminal
.
external
;
let
exec
=
terminalConfig
.
windowsExec
||
DEFAULT_TERMINAL_WINDOWS
;
// The '""' argument is the window title. Without this, exec doesn't work when the path
// contains spaces
let
cmdArgs
=
[
'
/c
'
,
'
start
'
,
'
/wait
'
,
'
""
'
,
exec
];
const
spawnType
=
this
.
getSpawnType
(
exec
);
// Make the drive letter uppercase on Windows (see #9448)
if
(
path
&&
path
[
1
]
===
'
:
'
)
{
path
=
path
[
0
].
toUpperCase
()
+
path
.
substr
(
1
);
}
// cmder ignores the environment cwd and instead opts to always open in %USERPROFILE%
// unless otherwise specified
if
(
spawnType
===
WinSpawnType
.
CMDER
)
{
spawner
.
spawn
(
exec
,
[
path
]);
return
TPromise
.
as
(
void
0
);
}
// The '""' argument is the window title. Without this, exec doesn't work when the path
// contains spaces
let
cmdArgs
=
[
'
/c
'
,
'
start
'
,
'
/wait
'
,
'
""
'
,
exec
];
return
new
TPromise
<
void
>
((
c
,
e
)
=>
{
let
env
=
path
?
{
cwd
:
path
}
:
void
0
;
let
child
=
spawner
.
spawn
(
command
,
cmdArgs
,
env
);
...
...
@@ -85,6 +100,14 @@ export class WinTerminalService implements ITerminalService {
child
.
on
(
'
exit
'
,
()
=>
c
(
null
));
});
}
private
getSpawnType
(
exec
:
string
):
WinSpawnType
{
const
basename
=
path
.
basename
(
exec
).
toLowerCase
();
if
(
basename
===
'
cmder
'
||
basename
===
'
cmder.exe
'
)
{
return
WinSpawnType
.
CMDER
;
}
return
WinSpawnType
.
CMD
;
}
}
export
class
MacTerminalService
implements
ITerminalService
{
...
...
src/vs/workbench/parts/execution/test/electron-browser/terminalService.test.ts
浏览文件 @
01b1d00a
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
equal
}
from
'
assert
'
;
import
{
deepEqual
,
equal
}
from
'
assert
'
;
import
{
WinTerminalService
,
LinuxTerminalService
,
MacTerminalService
}
from
'
vs/workbench/parts/execution/electron-browser/terminalService
'
;
import
{
DEFAULT_TERMINAL_WINDOWS
,
DEFAULT_TERMINAL_LINUX
,
DEFAULT_TERMINAL_OSX
}
from
'
vs/workbench/parts/execution/electron-browser/terminal
'
;
...
...
@@ -103,6 +103,30 @@ suite('Execution - TerminalService', () => {
);
});
test
(
"
WinTerminalService - cmder should be spawned differently
"
,
done
=>
{
let
testShell
=
'
cmd
'
;
mockConfig
.
terminal
.
external
.
windowsExec
=
'
cmder
'
;
let
testCwd
=
'
c:/foo
'
;
let
mockSpawner
=
{
spawn
:
(
command
,
args
,
opts
)
=>
{
// assert
deepEqual
(
args
,
[
'
C:/foo
'
]);
equal
(
opts
,
undefined
);
done
();
return
{
on
:
(
evt
)
=>
evt
};
}
};
let
testService
=
new
WinTerminalService
(
mockConfig
);
(
<
any
>
testService
).
spawnTerminal
(
mockSpawner
,
mockConfig
,
testShell
,
testCwd
,
mockOnExit
,
mockOnError
);
});
test
(
"
MacTerminalService - uses terminal from configuration
"
,
done
=>
{
let
testCwd
=
'
path/to/workspace
'
;
let
mockSpawner
=
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录