Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
83ba7099
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,发现更多精彩内容 >>
提交
83ba7099
编写于
6月 13, 2019
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Default shell API
Part of #75091
上级
8b0f06be
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
55 addition
and
12 deletion
+55
-12
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+6
-0
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+3
-0
src/vs/workbench/api/node/extHostTerminalService.ts
src/vs/workbench/api/node/extHostTerminalService.ts
+14
-1
src/vs/workbench/contrib/terminal/common/terminalEnvironment.ts
.../workbench/contrib/terminal/common/terminalEnvironment.ts
+32
-11
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
83ba7099
...
...
@@ -1110,6 +1110,12 @@ declare module 'vscode' {
}
namespace
window
{
/**
* The detected default shell for the extension host, this is overridden by the
* `terminal.integrated.shell` setting for the extension host's platform.
*/
export
const
shell
:
string
;
/**
* An event which fires when the [dimensions](#Terminal.dimensions) of the terminal change.
*/
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
83ba7099
...
...
@@ -391,6 +391,9 @@ export function createApiFactory(
get
terminals
()
{
return
extHostTerminalService
.
terminals
;
},
get
shell
()
{
return
extHostTerminalService
.
getDefaultShell
(
configProvider
);
},
showTextDocument
(
documentOrUri
:
vscode
.
TextDocument
|
vscode
.
Uri
,
columnOrOptions
?:
vscode
.
ViewColumn
|
vscode
.
TextDocumentShowOptions
,
preserveFocus
?:
boolean
):
Thenable
<
vscode
.
TextEditor
>
{
let
documentPromise
:
Promise
<
vscode
.
TextDocument
>
;
if
(
URI
.
isUri
(
documentOrUri
))
{
...
...
src/vs/workbench/api/node/extHostTerminalService.ts
浏览文件 @
83ba7099
...
...
@@ -11,7 +11,7 @@ import * as platform from 'vs/base/common/platform';
import
*
as
terminalEnvironment
from
'
vs/workbench/contrib/terminal/common/terminalEnvironment
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
ExtHostTerminalServiceShape
,
MainContext
,
MainThreadTerminalServiceShape
,
IMainContext
,
ShellLaunchConfigDto
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
ExtHostConfiguration
}
from
'
vs/workbench/api/common/extHostConfiguration
'
;
import
{
ExtHostConfiguration
,
ExtHostConfigProvider
}
from
'
vs/workbench/api/common/extHostConfiguration
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
EXT_HOST_CREATION_DELAY
,
IShellLaunchConfig
,
ITerminalEnvironment
}
from
'
vs/workbench/contrib/terminal/common/terminal
'
;
import
{
TerminalProcess
}
from
'
vs/workbench/contrib/terminal/node/terminalProcess
'
;
...
...
@@ -278,6 +278,9 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
private
_terminalRenderers
:
ExtHostTerminalRenderer
[]
=
[];
private
_getTerminalPromises
:
{
[
id
:
number
]:
Promise
<
ExtHostTerminal
>
}
=
{};
// TODO: Pull this from main side
private
_isWorkspaceShellAllowed
:
boolean
=
false
;
public
get
activeTerminal
():
ExtHostTerminal
|
undefined
{
return
this
.
_activeTerminal
;
}
public
get
terminals
():
ExtHostTerminal
[]
{
return
this
.
_terminals
;
}
...
...
@@ -325,6 +328,16 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
return
renderer
;
}
public
getDefaultShell
(
configProvider
:
ExtHostConfigProvider
):
string
{
const
fetchSetting
=
(
key
:
string
)
=>
{
const
setting
=
configProvider
.
getConfiguration
(
key
.
substr
(
0
,
key
.
lastIndexOf
(
'
.
'
)))
.
inspect
<
string
|
string
[]
>
(
key
.
substr
(
key
.
lastIndexOf
(
'
.
'
)
+
1
));
return
this
.
_apiInspectConfigToPlain
<
string
|
string
[]
>
(
setting
);
};
return
terminalEnvironment
.
getDefaultShell
(
fetchSetting
,
this
.
_isWorkspaceShellAllowed
,
getDefaultShell
(
platform
.
platform
));
}
public
async
resolveTerminalRenderer
(
id
:
number
):
Promise
<
vscode
.
TerminalRenderer
>
{
// Check to see if the extension host already knows about this terminal.
for
(
const
terminalRenderer
of
this
.
_terminalRenderers
)
{
...
...
src/vs/workbench/contrib/terminal/common/terminalEnvironment.ts
浏览文件 @
83ba7099
...
...
@@ -161,34 +161,55 @@ export function escapeNonWindowsPath(path: string): string {
return
newPath
;
}
export
function
mergeDefaultShellPathAndArgs
(
shell
:
IShellLaunchConfig
,
export
function
getDefaultShell
(
fetchSetting
:
(
key
:
string
)
=>
{
user
:
string
|
string
[]
|
undefined
,
value
:
string
|
string
[]
|
undefined
,
default
:
string
|
string
[]
|
undefined
},
isWorkspaceShellAllowed
:
boolean
,
defaultShell
:
string
,
platformOverride
:
platform
.
Platform
=
platform
.
platform
):
void
{
):
string
{
const
platformKey
=
platformOverride
===
platform
.
Platform
.
Windows
?
'
windows
'
:
platformOverride
===
platform
.
Platform
.
Mac
?
'
osx
'
:
'
linux
'
;
const
shellConfigValue
=
fetchSetting
(
`terminal.integrated.shell.
${
platformKey
}
`
);
const
shellArgsConfigValue
=
fetchSetting
(
`terminal.integrated.shellArgs.
${
platformKey
}
`
);
shell
.
executable
=
(
isWorkspaceShellAllowed
?
<
string
>
shellConfigValue
.
value
:
<
string
>
shellConfigValue
.
user
)
||
(
<
string
|
null
>
shellConfigValue
.
default
||
defaultShell
);
shell
.
args
=
(
isWorkspaceShellAllowed
?
<
string
[]
>
shellArgsConfigValue
.
value
:
<
string
[]
>
shellArgsConfigValue
.
user
)
||
<
string
[]
>
shellArgsConfigValue
.
default
;
let
executable
=
(
isWorkspaceShellAllowed
?
<
string
>
shellConfigValue
.
value
:
<
string
>
shellConfigValue
.
user
)
||
(
<
string
|
null
>
shellConfigValue
.
default
||
defaultShell
);
// Change Sysnative to System32 if the OS is Windows but NOT WoW64. It's
// safe to assume that this was used by accident as Sysnative does not
// exist and will break the terminal in non-WoW64 environments.
if
((
platformOverride
===
platform
.
Platform
.
Windows
)
&&
!
process
.
env
.
hasOwnProperty
(
'
PROCESSOR_ARCHITEW6432
'
)
&&
process
.
env
.
windir
)
{
const
sysnativePath
=
path
.
join
(
process
.
env
.
windir
,
'
Sysnative
'
).
toLowerCase
();
if
(
shell
.
executable
&&
shell
.
executable
.
toLowerCase
().
indexOf
(
sysnativePath
)
===
0
)
{
shell
.
executable
=
path
.
join
(
process
.
env
.
windir
,
'
System32
'
,
shell
.
executable
.
substr
(
sysnativePath
.
length
));
if
(
executable
&&
executable
.
toLowerCase
().
indexOf
(
sysnativePath
)
===
0
)
{
executable
=
path
.
join
(
process
.
env
.
windir
,
'
System32
'
,
executable
.
substr
(
sysnativePath
.
length
));
}
}
// Convert / to \ on Windows for convenience
if
(
shell
.
executable
&&
platformOverride
===
platform
.
Platform
.
Windows
)
{
shell
.
executable
=
shell
.
executable
.
replace
(
/
\/
/g
,
'
\\
'
);
if
(
executable
&&
platformOverride
===
platform
.
Platform
.
Windows
)
{
executable
=
executable
.
replace
(
/
\/
/g
,
'
\\
'
);
}
return
executable
;
}
function
getDefaultShellArgs
(
fetchSetting
:
(
key
:
string
)
=>
{
user
:
string
|
string
[]
|
undefined
,
value
:
string
|
string
[]
|
undefined
,
default
:
string
|
string
[]
|
undefined
},
isWorkspaceShellAllowed
:
boolean
,
defaultShell
:
string
,
platformOverride
:
platform
.
Platform
=
platform
.
platform
):
string
[]
{
const
platformKey
=
platformOverride
===
platform
.
Platform
.
Windows
?
'
windows
'
:
platformOverride
===
platform
.
Platform
.
Mac
?
'
osx
'
:
'
linux
'
;
const
shellArgsConfigValue
=
fetchSetting
(
`terminal.integrated.shellArgs.
${
platformKey
}
`
);
const
args
=
(
isWorkspaceShellAllowed
?
<
string
[]
>
shellArgsConfigValue
.
value
:
<
string
[]
>
shellArgsConfigValue
.
user
)
||
<
string
[]
>
shellArgsConfigValue
.
default
;
return
args
;
}
export
function
mergeDefaultShellPathAndArgs
(
shell
:
IShellLaunchConfig
,
fetchSetting
:
(
key
:
string
)
=>
{
user
:
string
|
string
[]
|
undefined
,
value
:
string
|
string
[]
|
undefined
,
default
:
string
|
string
[]
|
undefined
},
isWorkspaceShellAllowed
:
boolean
,
defaultShell
:
string
,
platformOverride
:
platform
.
Platform
=
platform
.
platform
):
void
{
shell
.
executable
=
getDefaultShell
(
fetchSetting
,
isWorkspaceShellAllowed
,
defaultShell
,
platformOverride
);
shell
.
args
=
getDefaultShellArgs
(
fetchSetting
,
isWorkspaceShellAllowed
,
defaultShell
,
platformOverride
);
}
export
function
createTerminalEnvironment
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录