Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
10d4256f
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,发现更多精彩内容 >>
提交
10d4256f
编写于
6月 14, 2019
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove process usage from terminalEnvironment
Fixes #75509
上级
2935ccca
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
57 addition
and
25 deletion
+57
-25
src/vs/workbench/api/node/extHostTerminalService.ts
src/vs/workbench/api/node/extHostTerminalService.ts
+15
-2
src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts
...ench/contrib/tasks/electron-browser/terminalTaskSystem.ts
+1
-1
src/vs/workbench/contrib/terminal/browser/terminal.ts
src/vs/workbench/contrib/terminal/browser/terminal.ts
+4
-0
src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts
...orkbench/contrib/terminal/browser/terminalConfigHelper.ts
+1
-7
src/vs/workbench/contrib/terminal/browser/terminalInstanceService.ts
...bench/contrib/terminal/browser/terminalInstanceService.ts
+3
-0
src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts
...kbench/contrib/terminal/browser/terminalProcessManager.ts
+1
-1
src/vs/workbench/contrib/terminal/common/terminal.ts
src/vs/workbench/contrib/terminal/common/terminal.ts
+1
-5
src/vs/workbench/contrib/terminal/common/terminalEnvironment.ts
.../workbench/contrib/terminal/common/terminalEnvironment.ts
+9
-6
src/vs/workbench/contrib/terminal/electron-browser/terminalInstanceService.ts
...trib/terminal/electron-browser/terminalInstanceService.ts
+19
-3
src/vs/workbench/contrib/terminal/test/electron-browser/terminalLinkHandler.test.ts
...erminal/test/electron-browser/terminalLinkHandler.test.ts
+3
-0
未找到文件。
src/vs/workbench/api/node/extHostTerminalService.ts
浏览文件 @
10d4256f
...
...
@@ -335,7 +335,13 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
.
inspect
<
string
|
string
[]
>
(
key
.
substr
(
key
.
lastIndexOf
(
'
.
'
)
+
1
));
return
this
.
_apiInspectConfigToPlain
<
string
|
string
[]
>
(
setting
);
};
return
terminalEnvironment
.
getDefaultShell
(
fetchSetting
,
this
.
_isWorkspaceShellAllowed
,
getDefaultShell
(
platform
.
platform
));
return
terminalEnvironment
.
getDefaultShell
(
fetchSetting
,
this
.
_isWorkspaceShellAllowed
,
getDefaultShell
(
platform
.
platform
),
process
.
env
.
hasOwnProperty
(
'
PROCESSOR_ARCHITEW6432
'
),
process
.
env
.
windir
);
}
public
async
resolveTerminalRenderer
(
id
:
number
):
Promise
<
vscode
.
TerminalRenderer
>
{
...
...
@@ -485,7 +491,14 @@ export class ExtHostTerminalService implements ExtHostTerminalServiceShape {
.
inspect
<
string
|
string
[]
>
(
key
.
substr
(
key
.
lastIndexOf
(
'
.
'
)
+
1
));
return
this
.
_apiInspectConfigToPlain
<
string
|
string
[]
>
(
setting
);
};
terminalEnvironment
.
mergeDefaultShellPathAndArgs
(
shellLaunchConfig
,
fetchSetting
,
isWorkspaceShellAllowed
||
false
,
getDefaultShell
(
platform
.
platform
));
terminalEnvironment
.
mergeDefaultShellPathAndArgs
(
shellLaunchConfig
,
fetchSetting
,
isWorkspaceShellAllowed
||
false
,
getDefaultShell
(
platform
.
platform
),
process
.
env
.
hasOwnProperty
(
'
PROCESSOR_ARCHITEW6432
'
),
process
.
env
.
windir
);
}
// Get the initial cwd
...
...
src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts
浏览文件 @
10d4256f
...
...
@@ -779,7 +779,7 @@ export class TerminalTaskSystem implements ITaskSystem {
let
originalCommand
=
task
.
command
.
name
;
if
(
isShellCommand
)
{
shellLaunchConfig
=
{
name
:
terminalName
,
executable
:
undefined
,
args
:
undefined
,
waitOnExit
};
this
.
terminal
Service
.
configHelper
.
mergeDefaultShellPathAndArgs
(
shellLaunchConfig
,
this
.
getDefaultShell
(
platform
)
,
platform
);
this
.
terminal
InstanceService
.
mergeDefaultShellPathAndArgs
(
shellLaunchConfig
,
this
.
getDefaultShell
(
platform
),
this
.
terminalService
.
configHelper
,
platform
);
let
shellSpecified
:
boolean
=
false
;
let
shellOptions
:
ShellConfiguration
|
undefined
=
task
.
command
.
options
&&
task
.
command
.
options
.
shell
;
if
(
shellOptions
)
{
...
...
src/vs/workbench/contrib/terminal/browser/terminal.ts
浏览文件 @
10d4256f
...
...
@@ -26,6 +26,10 @@ export interface ITerminalInstanceService {
createWindowsShellHelper
(
shellProcessId
:
number
,
instance
:
ITerminalInstance
,
xterm
:
XTermTerminal
):
IWindowsShellHelper
;
createTerminalProcess
(
shellLaunchConfig
:
IShellLaunchConfig
,
cwd
:
string
,
cols
:
number
,
rows
:
number
,
env
:
IProcessEnvironment
,
windowsEnableConpty
:
boolean
):
ITerminalChildProcess
;
getDefaultShell
(
p
:
Platform
):
string
;
/**
* Merges the default shell path and args into the provided launch configuration
*/
mergeDefaultShellPathAndArgs
(
shell
:
IShellLaunchConfig
,
defaultShell
:
string
,
configHelper
:
ITerminalConfigHelper
,
platformOverride
?:
Platform
):
void
;
getMainProcessParentEnv
():
Promise
<
IProcessEnvironment
>
;
}
...
...
src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts
浏览文件 @
10d4256f
...
...
@@ -8,12 +8,11 @@ import * as platform from 'vs/base/common/platform';
import
{
EDITOR_FONT_DEFAULTS
,
IEditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
{
ITerminalConfiguration
,
ITerminalFont
,
IS
hellLaunchConfig
,
IS
_WORKSPACE_SHELL_ALLOWED_STORAGE_KEY
,
TERMINAL_CONFIG_SECTION
,
DEFAULT_LETTER_SPACING
,
DEFAULT_LINE_HEIGHT
,
MINIMUM_LETTER_SPACING
,
LinuxDistro
}
from
'
vs/workbench/contrib/terminal/common/terminal
'
;
import
{
ITerminalConfiguration
,
ITerminalFont
,
IS_WORKSPACE_SHELL_ALLOWED_STORAGE_KEY
,
TERMINAL_CONFIG_SECTION
,
DEFAULT_LETTER_SPACING
,
DEFAULT_LINE_HEIGHT
,
MINIMUM_LETTER_SPACING
,
LinuxDistro
}
from
'
vs/workbench/contrib/terminal/common/terminal
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
{
Terminal
as
XTermTerminal
}
from
'
xterm
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
IBrowserTerminalConfigHelper
}
from
'
vs/workbench/contrib/terminal/browser/terminal
'
;
import
{
mergeDefaultShellPathAndArgs
}
from
'
vs/workbench/contrib/terminal/common/terminalEnvironment
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
const
MINIMUM_FONT_SIZE
=
6
;
...
...
@@ -232,11 +231,6 @@ export class TerminalConfigHelper implements IBrowserTerminalConfigHelper {
return
!!
isWorkspaceShellAllowed
;
}
public
mergeDefaultShellPathAndArgs
(
shell
:
IShellLaunchConfig
,
defaultShell
:
string
,
platformOverride
:
platform
.
Platform
=
platform
.
platform
):
void
{
const
isWorkspaceShellAllowed
=
this
.
checkWorkspaceShellPermissions
(
platformOverride
===
platform
.
Platform
.
Windows
?
platform
.
OperatingSystem
.
Windows
:
(
platformOverride
===
platform
.
Platform
.
Mac
?
platform
.
OperatingSystem
.
Macintosh
:
platform
.
OperatingSystem
.
Linux
));
mergeDefaultShellPathAndArgs
(
shell
,
(
key
)
=>
this
.
_workspaceConfigurationService
.
inspect
(
key
),
isWorkspaceShellAllowed
,
defaultShell
,
platformOverride
);
}
private
_toInteger
(
source
:
any
,
minimum
:
number
,
maximum
:
number
,
fallback
:
number
):
number
{
let
r
=
parseInt
(
source
,
10
);
if
(
isNaN
(
r
))
{
...
...
src/vs/workbench/contrib/terminal/browser/terminalInstanceService.ts
浏览文件 @
10d4256f
...
...
@@ -55,4 +55,7 @@ export class TerminalInstanceService implements ITerminalInstanceService {
public
async
getMainProcessParentEnv
():
Promise
<
IProcessEnvironment
>
{
return
{};
}
public
mergeDefaultShellPathAndArgs
():
void
{
}
}
\ No newline at end of file
src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts
浏览文件 @
10d4256f
...
...
@@ -161,7 +161,7 @@ export class TerminalProcessManager implements ITerminalProcessManager {
private
async
_launchProcess
(
shellLaunchConfig
:
IShellLaunchConfig
,
cols
:
number
,
rows
:
number
):
Promise
<
ITerminalChildProcess
>
{
if
(
!
shellLaunchConfig
.
executable
)
{
this
.
_
configHelper
.
mergeDefaultShellPathAndArgs
(
shellLaunchConfig
,
this
.
_terminalInstanceService
.
getDefaultShell
(
platform
.
platform
)
);
this
.
_
terminalInstanceService
.
mergeDefaultShellPathAndArgs
(
shellLaunchConfig
,
this
.
_terminalInstanceService
.
getDefaultShell
(
platform
.
platform
),
this
.
_configHelper
);
}
const
activeWorkspaceRootUri
=
this
.
_historyService
.
getLastActiveWorkspaceRoot
(
Schemas
.
file
);
...
...
src/vs/workbench/contrib/terminal/common/terminal.ts
浏览文件 @
10d4256f
...
...
@@ -9,7 +9,7 @@ import { RawContextKey, ContextKeyExpr, IContextKey } from 'vs/platform/contextk
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
FindReplaceState
}
from
'
vs/editor/contrib/find/findState
'
;
import
{
Platform
,
OperatingSystem
}
from
'
vs/base/common/platform
'
;
import
{
OperatingSystem
}
from
'
vs/base/common/platform
'
;
import
{
IOpenFileRequest
}
from
'
vs/platform/windows/common/windows
'
;
export
const
TERMINAL_PANEL_ID
=
'
workbench.panel.terminal
'
;
...
...
@@ -114,10 +114,6 @@ export interface ITerminalConfigHelper {
configFontIsMonospace
():
boolean
;
getFont
():
ITerminalFont
;
/**
* Merges the default shell path and args into the provided launch configuration
*/
mergeDefaultShellPathAndArgs
(
shell
:
IShellLaunchConfig
,
defaultShell
:
string
,
platformOverride
?:
Platform
):
void
;
/** Sets whether a workspace shell configuration is allowed or not */
setWorkspaceShellAllowed
(
isAllowed
:
boolean
):
void
;
checkWorkspaceShellPermissions
(
osOverride
?:
OperatingSystem
):
boolean
;
...
...
src/vs/workbench/contrib/terminal/common/terminalEnvironment.ts
浏览文件 @
10d4256f
...
...
@@ -166,6 +166,8 @@ export function getDefaultShell(
fetchSetting
:
(
key
:
string
)
=>
{
user
:
string
|
string
[]
|
undefined
,
value
:
string
|
string
[]
|
undefined
,
default
:
string
|
string
[]
|
undefined
},
isWorkspaceShellAllowed
:
boolean
,
defaultShell
:
string
,
isWoW64
:
boolean
,
windir
:
string
|
undefined
,
platformOverride
:
platform
.
Platform
=
platform
.
platform
):
string
{
const
platformKey
=
platformOverride
===
platform
.
Platform
.
Windows
?
'
windows
'
:
platformOverride
===
platform
.
Platform
.
Mac
?
'
osx
'
:
'
linux
'
;
...
...
@@ -175,10 +177,10 @@ export function getDefaultShell(
// 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
((
platformOverride
===
platform
.
Platform
.
Windows
)
&&
!
isWoW64
&&
windir
)
{
const
sysnativePath
=
path
.
join
(
windir
,
'
Sysnative
'
).
toLowerCase
();
if
(
executable
&&
executable
.
toLowerCase
().
indexOf
(
sysnativePath
)
===
0
)
{
executable
=
path
.
join
(
process
.
env
.
windir
,
'
System32
'
,
executable
.
substr
(
sysnativePath
.
length
));
executable
=
path
.
join
(
windir
,
'
System32
'
,
executable
.
substr
(
sysnativePath
.
length
));
}
}
...
...
@@ -193,7 +195,6 @@ export function getDefaultShell(
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
'
;
...
...
@@ -207,10 +208,12 @@ export function mergeDefaultShellPathAndArgs(
fetchSetting
:
(
key
:
string
)
=>
{
user
:
string
|
string
[]
|
undefined
,
value
:
string
|
string
[]
|
undefined
,
default
:
string
|
string
[]
|
undefined
},
isWorkspaceShellAllowed
:
boolean
,
defaultShell
:
string
,
isWoW64
:
boolean
,
windir
:
string
|
undefined
,
platformOverride
:
platform
.
Platform
=
platform
.
platform
):
void
{
shell
.
executable
=
getDefaultShell
(
fetchSetting
,
isWorkspaceShellAllowed
,
defaultShell
,
platformOverride
);
shell
.
args
=
getDefaultShellArgs
(
fetchSetting
,
isWorkspaceShellAllowed
,
defaultShell
,
platformOverride
);
shell
.
executable
=
getDefaultShell
(
fetchSetting
,
isWorkspaceShellAllowed
,
defaultShell
,
isWoW64
,
windir
,
platformOverride
);
shell
.
args
=
getDefaultShellArgs
(
fetchSetting
,
isWorkspaceShellAllowed
,
platformOverride
);
}
export
function
createTerminalEnvironment
(
...
...
src/vs/workbench/contrib/terminal/electron-browser/terminalInstanceService.ts
浏览文件 @
10d4256f
...
...
@@ -4,10 +4,10 @@
*--------------------------------------------------------------------------------------------*/
import
{
ITerminalInstanceService
}
from
'
vs/workbench/contrib/terminal/browser/terminal
'
;
import
{
ITerminalInstance
,
IWindowsShellHelper
,
IShellLaunchConfig
,
ITerminalChildProcess
}
from
'
vs/workbench/contrib/terminal/common/terminal
'
;
import
{
ITerminalInstance
,
IWindowsShellHelper
,
IShellLaunchConfig
,
ITerminalChildProcess
,
ITerminalConfigHelper
}
from
'
vs/workbench/contrib/terminal/common/terminal
'
;
import
{
WindowsShellHelper
}
from
'
vs/workbench/contrib/terminal/node/windowsShellHelper
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IProcessEnvironment
,
Platform
,
isLinux
,
isMacintosh
,
isWindows
}
from
'
vs/base/common/platform
'
;
import
{
IProcessEnvironment
,
Platform
,
isLinux
,
isMacintosh
,
isWindows
,
OperatingSystem
,
platform
}
from
'
vs/base/common/platform
'
;
import
{
TerminalProcess
}
from
'
vs/workbench/contrib/terminal/node/terminalProcess
'
;
import
{
getDefaultShell
}
from
'
vs/workbench/contrib/terminal/node/terminal
'
;
import
{
Terminal
as
XTermTerminal
}
from
'
xterm
'
;
...
...
@@ -15,6 +15,8 @@ import { WebLinksAddon as XTermWebLinksAddon } from 'xterm-addon-web-links';
import
{
SearchAddon
as
XTermSearchAddon
}
from
'
xterm-addon-search
'
;
import
{
readFile
}
from
'
vs/base/node/pfs
'
;
import
{
basename
}
from
'
vs/base/common/path
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
mergeDefaultShellPathAndArgs
}
from
'
vs/workbench/contrib/terminal/common/terminalEnvironment
'
;
let
Terminal
:
typeof
XTermTerminal
;
let
WebLinksAddon
:
typeof
XTermWebLinksAddon
;
...
...
@@ -26,7 +28,8 @@ export class TerminalInstanceService implements ITerminalInstanceService {
private
_mainProcessParentEnv
:
IProcessEnvironment
|
undefined
;
constructor
(
@
IInstantiationService
private
readonly
_instantiationService
:
IInstantiationService
@
IInstantiationService
private
readonly
_instantiationService
:
IInstantiationService
,
@
IConfigurationService
private
readonly
_configurationService
:
IConfigurationService
)
{
}
...
...
@@ -63,6 +66,19 @@ export class TerminalInstanceService implements ITerminalInstanceService {
return
getDefaultShell
(
p
);
}
public
mergeDefaultShellPathAndArgs
(
shell
:
IShellLaunchConfig
,
defaultShell
:
string
,
configHelper
:
ITerminalConfigHelper
,
platformOverride
:
Platform
=
platform
):
void
{
const
isWorkspaceShellAllowed
=
configHelper
.
checkWorkspaceShellPermissions
(
platformOverride
===
Platform
.
Windows
?
OperatingSystem
.
Windows
:
(
platformOverride
===
Platform
.
Mac
?
OperatingSystem
.
Macintosh
:
OperatingSystem
.
Linux
));
mergeDefaultShellPathAndArgs
(
shell
,
(
key
)
=>
this
.
_configurationService
.
inspect
(
key
),
isWorkspaceShellAllowed
,
defaultShell
,
process
.
env
.
hasOwnProperty
(
'
PROCESSOR_ARCHITEW6432
'
),
process
.
env
.
windir
,
platformOverride
);
}
public
async
getMainProcessParentEnv
():
Promise
<
IProcessEnvironment
>
{
if
(
this
.
_mainProcessParentEnv
)
{
return
this
.
_mainProcessParentEnv
;
...
...
src/vs/workbench/contrib/terminal/test/electron-browser/terminalLinkHandler.test.ts
浏览文件 @
10d4256f
...
...
@@ -30,6 +30,9 @@ class TestXterm {
}
class
MockTerminalInstanceService
implements
ITerminalInstanceService
{
mergeDefaultShellPathAndArgs
():
void
{
throw
new
Error
(
'
Method not implemented.
'
);
}
_serviceBrand
:
any
;
getXtermConstructor
():
Promise
<
any
>
{
throw
new
Error
(
'
Method not implemented.
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录