Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f62ddfb9
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,发现更多精彩内容 >>
提交
f62ddfb9
编写于
12月 13, 2018
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Strict null check terminalProcessManager
Part of #65035
上级
ec1ca5ec
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
28 addition
and
17 deletion
+28
-17
src/tsconfig.strictNullChecks.json
src/tsconfig.strictNullChecks.json
+1
-0
src/vs/workbench/parts/terminal/common/terminal.ts
src/vs/workbench/parts/terminal/common/terminal.ts
+5
-1
src/vs/workbench/parts/terminal/electron-browser/terminalProcessManager.ts
...parts/terminal/electron-browser/terminalProcessManager.ts
+13
-8
src/vs/workbench/parts/terminal/node/terminalEnvironment.ts
src/vs/workbench/parts/terminal/node/terminalEnvironment.ts
+9
-8
未找到文件。
src/tsconfig.strictNullChecks.json
浏览文件 @
f62ddfb9
...
...
@@ -648,6 +648,7 @@
"./vs/workbench/parts/terminal/common/terminalMenu.ts"
,
"./vs/workbench/parts/terminal/common/terminalService.ts"
,
"./vs/workbench/parts/terminal/electron-browser/terminalConfigHelper.ts"
,
"./vs/workbench/parts/terminal/electron-browser/terminalProcessManager.ts"
,
"./vs/workbench/parts/terminal/node/terminal.ts"
,
"./vs/workbench/parts/terminal/node/terminalCommandTracker.ts"
,
"./vs/workbench/parts/terminal/node/terminalEnvironment.ts"
,
...
...
src/vs/workbench/parts/terminal/common/terminal.ts
浏览文件 @
f62ddfb9
...
...
@@ -124,6 +124,10 @@ export interface ITerminalFont {
charHeight
?:
number
;
}
export
interface
ITerminalEnvironment
{
[
key
:
string
]:
string
|
null
;
}
export
interface
IShellLaunchConfig
{
/**
* The name of the terminal, if this is not set the name of the process will be used.
...
...
@@ -152,7 +156,7 @@ export interface IShellLaunchConfig {
* A custom environment for the terminal, if this is not set the environment will be inherited
* from the VS Code process.
*/
env
?:
{
[
key
:
string
]:
string
}
;
env
?:
ITerminalEnvironment
;
/**
* Whether to ignore a custom cwd from the `terminal.integrated.cwd` settings key (eg. if the
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalProcessManager.ts
浏览文件 @
f62ddfb9
...
...
@@ -37,7 +37,7 @@ export class TerminalProcessManager implements ITerminalProcessManager {
public
shellProcessId
:
number
;
public
initialCwd
:
string
;
private
_process
:
ITerminalChildProcess
;
private
_process
:
ITerminalChildProcess
|
null
=
null
;
private
_preLaunchInputQueue
:
string
[]
=
[];
private
_disposables
:
IDisposable
[]
=
[];
...
...
@@ -68,7 +68,7 @@ export class TerminalProcessManager implements ITerminalProcessManager {
});
}
public
dispose
(
immediate
?:
boolean
):
void
{
public
dispose
(
immediate
:
boolean
=
false
):
void
{
if
(
this
.
_process
)
{
// If the process was still connected this dispose came from
// within VS Code, not the process, so mark the process as
...
...
@@ -108,8 +108,10 @@ export class TerminalProcessManager implements ITerminalProcessManager {
const
envFromShell
=
terminalEnvironment
.
resolveConfigurationVariables
(
this
.
_configurationResolverService
,
{
...
shellLaunchConfig
.
env
},
lastActiveWorkspaceRoot
);
shellLaunchConfig
.
env
=
envFromShell
;
// Compell type system as process.env should not have any undefined entries
const
env
:
platform
.
IProcessEnvironment
=
{
...
process
.
env
}
as
any
;
// Merge process env with the env from config and from shellLaunchConfig
const
env
=
{
...
process
.
env
};
terminalEnvironment
.
mergeEnvironments
(
env
,
envFromConfig
);
terminalEnvironment
.
mergeEnvironments
(
env
,
shellLaunchConfig
.
env
);
...
...
@@ -126,23 +128,26 @@ export class TerminalProcessManager implements ITerminalProcessManager {
}
this
.
processState
=
ProcessState
.
LAUNCHING
;
this
.
_process
.
onProcessData
(
data
=>
{
// The process is non-null, but TS isn't clever enough to know
const
p
=
this
.
_process
!
;
p
.
onProcessData
(
data
=>
{
this
.
_onProcessData
.
fire
(
data
);
});
this
.
_process
.
onProcessIdReady
(
pid
=>
{
p
.
onProcessIdReady
(
pid
=>
{
this
.
shellProcessId
=
pid
;
this
.
_onProcessReady
.
fire
();
// Send any queued data that's waiting
if
(
this
.
_preLaunchInputQueue
.
length
>
0
)
{
this
.
_process
.
input
(
this
.
_preLaunchInputQueue
.
join
(
''
));
p
.
input
(
this
.
_preLaunchInputQueue
.
join
(
''
));
this
.
_preLaunchInputQueue
.
length
=
0
;
}
});
this
.
_process
.
onProcessTitleChanged
(
title
=>
this
.
_onProcessTitle
.
fire
(
title
));
this
.
_process
.
onProcessExit
(
exitCode
=>
this
.
_onExit
(
exitCode
));
p
.
onProcessTitleChanged
(
title
=>
this
.
_onProcessTitle
.
fire
(
title
));
p
.
onProcessExit
(
exitCode
=>
this
.
_onExit
(
exitCode
));
setTimeout
(()
=>
{
if
(
this
.
processState
===
ProcessState
.
LAUNCHING
)
{
...
...
src/vs/workbench/parts/terminal/node/terminalEnvironment.ts
浏览文件 @
f62ddfb9
...
...
@@ -9,14 +9,14 @@ import * as platform from 'vs/base/common/platform';
import
pkg
from
'
vs/platform/node/package
'
;
import
{
URI
as
Uri
}
from
'
vs/base/common/uri
'
;
import
{
IWorkspaceFolder
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IShellLaunchConfig
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
IShellLaunchConfig
,
ITerminalEnvironment
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
IConfigurationResolverService
}
from
'
vs/workbench/services/configurationResolver/common/configurationResolver
'
;
/**
* This module contains utility functions related to the environment, cwd and paths.
*/
export
function
mergeEnvironments
(
parent
:
platform
.
IProcessEnvironment
,
other
:
platform
.
IProcess
Environment
):
void
{
export
function
mergeEnvironments
(
parent
:
platform
.
IProcessEnvironment
,
other
:
ITerminal
Environment
):
void
{
if
(
!
other
)
{
return
;
}
...
...
@@ -43,7 +43,7 @@ export function mergeEnvironments(parent: platform.IProcessEnvironment, other: p
}
}
function
_mergeEnvironmentValue
(
env
:
platform
.
IProcess
Environment
,
key
:
string
,
value
:
string
|
null
):
void
{
function
_mergeEnvironmentValue
(
env
:
ITerminal
Environment
,
key
:
string
,
value
:
string
|
null
):
void
{
if
(
typeof
value
===
'
string
'
)
{
env
[
key
]
=
value
;
}
else
{
...
...
@@ -51,7 +51,7 @@ function _mergeEnvironmentValue(env: platform.IProcessEnvironment, key: string,
}
}
export
function
sanitizeEnvironment
(
env
:
platform
.
IProcess
Environment
):
void
{
export
function
sanitizeEnvironment
(
env
:
ITerminal
Environment
):
void
{
// Remove keys based on strings
const
keysToRemove
=
[
'
ELECTRON_ENABLE_STACK_DUMPING
'
,
...
...
@@ -76,16 +76,17 @@ export function sanitizeEnvironment(env: platform.IProcessEnvironment): void {
});
}
export
function
addTerminalEnvironmentKeys
(
env
:
platform
.
IProcess
Environment
,
locale
:
string
|
undefined
):
void
{
export
function
addTerminalEnvironmentKeys
(
env
:
ITerminal
Environment
,
locale
:
string
|
undefined
):
void
{
env
[
'
TERM_PROGRAM
'
]
=
'
vscode
'
;
env
[
'
TERM_PROGRAM_VERSION
'
]
=
pkg
.
version
;
env
[
'
LANG
'
]
=
_getLangEnvVariable
(
locale
);
}
export
function
resolveConfigurationVariables
(
configurationResolverService
:
IConfigurationResolverService
,
env
:
platform
.
IProcessEnvironment
,
lastActiveWorkspaceRoot
:
IWorkspaceFolder
):
platform
.
IProcess
Environment
{
export
function
resolveConfigurationVariables
(
configurationResolverService
:
IConfigurationResolverService
,
env
:
ITerminalEnvironment
,
lastActiveWorkspaceRoot
:
IWorkspaceFolder
|
null
):
ITerminal
Environment
{
Object
.
keys
(
env
).
forEach
((
key
)
=>
{
if
(
typeof
env
[
key
]
===
'
string
'
)
{
env
[
key
]
=
configurationResolverService
.
resolve
(
lastActiveWorkspaceRoot
,
env
[
key
]);
const
value
=
env
[
key
];
if
(
typeof
value
===
'
string
'
&&
lastActiveWorkspaceRoot
!==
null
)
{
env
[
key
]
=
configurationResolverService
.
resolve
(
lastActiveWorkspaceRoot
,
value
);
}
});
return
env
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录