Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
68160413
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,发现更多精彩内容 >>
提交
68160413
编写于
4月 13, 2018
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean up
上级
394b7ece
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
69 deletion
+14
-69
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
...bench/parts/terminal/electron-browser/terminalInstance.ts
+2
-68
src/vs/workbench/parts/terminal/electron-browser/terminalProcessManager.ts
...parts/terminal/electron-browser/terminalProcessManager.ts
+12
-1
未找到文件。
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
浏览文件 @
68160413
...
...
@@ -14,7 +14,7 @@ import { Terminal as XTermTerminal } from 'vscode-xterm';
import
{
IContextKeyService
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IPanelService
}
from
'
vs/workbench/services/panel/common/panelService
'
;
import
{
ITerminalInstance
,
KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED
,
TERMINAL_PANEL_ID
,
IShellLaunchConfig
,
ITerminalProcessManager
,
ITerminalProcessMessag
e
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
ITerminalInstance
,
KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED
,
TERMINAL_PANEL_ID
,
IShellLaunchConfig
,
ITerminalProcessManager
,
ProcessStat
e
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
TabFocus
}
from
'
vs/editor/common/config/commonEditorConfig
'
;
...
...
@@ -34,30 +34,8 @@ import { ILogService } from 'vs/platform/log/common/log';
import
{
TerminalCommandTracker
}
from
'
vs/workbench/parts/terminal/node/terminalCommandTracker
'
;
import
{
TerminalProcessManager
}
from
'
./terminalProcessManager
'
;
/** The amount of time to consider terminal errors to be related to the launch */
const
LAUNCHING_DURATION
=
500
;
let
Terminal
:
typeof
XTermTerminal
;
enum
ProcessState
{
// The process has not been initialized yet.
UNINITIALIZED
,
// The process is currently launching, the process is marked as launching
// for a short duration after being created and is helpful to indicate
// whether the process died as a result of bad shell and args.
LAUNCHING
,
// The process is running normally.
RUNNING
,
// The process was killed during launch, likely as a result of bad shell and
// args.
KILLED_DURING_LAUNCH
,
// The process was killed by the user (the event originated from VS Code).
KILLED_BY_USER
,
// The process was killed by itself, for example the shell crashed or `exit`
// was run.
KILLED_BY_PROCESS
}
export
class
TerminalInstance
implements
ITerminalInstance
{
private
static
readonly
EOL_REGEX
=
/
\r?\n
/g
;
...
...
@@ -70,20 +48,15 @@ export class TerminalInstance implements ITerminalInstance {
private
_isExiting
:
boolean
;
private
_hadFocusOnExit
:
boolean
;
private
_isVisible
:
boolean
;
// private _processState: ProcessState;
// private _processReady: TPromise<void>;
private
_isDisposed
:
boolean
;
private
readonly
_onDisposed
:
Emitter
<
ITerminalInstance
>
;
private
readonly
_onFocused
:
Emitter
<
ITerminalInstance
>
;
private
readonly
_onProcessIdReady
:
Emitter
<
ITerminalInstance
>
;
private
readonly
_onTitleChanged
:
Emitter
<
string
>
;
// private _process: cp.ChildProcess;
// private _processId: number;
private
_skipTerminalCommands
:
string
[];
private
_title
:
string
;
// TODO: Rename to "_disposables"
private
_instanceDisposables
:
lifecycle
.
IDisposable
[];
// private _processDisposables: lifecycle.IDisposable[];
private
_wrapperElement
:
HTMLDivElement
;
private
_xterm
:
XTermTerminal
;
private
_xtermElement
:
HTMLDivElement
;
...
...
@@ -91,8 +64,6 @@ export class TerminalInstance implements ITerminalInstance {
private
_cols
:
number
;
private
_rows
:
number
;
private
_messageTitleListener
:
(
message
:
{
type
:
string
,
content
:
string
})
=>
void
;
// private _preLaunchInputQueue: string;
// private _initialCwd: string;
private
_windowsShellHelper
:
WindowsShellHelper
;
private
_onLineDataListeners
:
((
lineData
:
string
)
=>
void
)[];
private
_xtermReadyPromise
:
TPromise
<
void
>
;
...
...
@@ -141,7 +112,6 @@ export class TerminalInstance implements ITerminalInstance {
this
.
_isDisposed
=
false
;
this
.
_id
=
TerminalInstance
.
_idCounter
++
;
this
.
_terminalHasTextContextKey
=
KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED
.
bindTo
(
this
.
_contextKeyService
);
// this._preLaunchInputQueue = '';
this
.
disableLayout
=
false
;
this
.
_logService
.
trace
(
`terminalInstance#ctor (id:
${
this
.
id
}
)`
,
this
.
_shellLaunchConfig
);
...
...
@@ -631,34 +601,6 @@ export class TerminalInstance implements ITerminalInstance {
this
.
_processManager
.
onShellProcessIdReady
(()
=>
this
.
_onProcessIdReady
.
fire
(
this
));
this
.
_processManager
.
createProcess
(
this
.
_shellLaunchConfig
);
// const locale = this._configHelper.config.setLocaleVariables ? platform.locale : undefined;
// if (!this._shellLaunchConfig.executable) {
// this._configHelper.mergeDefaultShellPathAndArgs(this._shellLaunchConfig);
// }
// const lastActiveWorkspaceRootUri = this._historyService.getLastActiveWorkspaceRoot('file');
// this._initialCwd = this._getCwd(this._shellLaunchConfig, lastActiveWorkspaceRootUri);
// // Resolve env vars from config and shell
// const lastActiveWorkspaceRoot = this._workspaceContextService.getWorkspaceFolder(lastActiveWorkspaceRootUri);
// const platformKey = platform.isWindows ? 'windows' : (platform.isMacintosh ? 'osx' : 'linux');
// const envFromConfig = TerminalInstance.resolveConfigurationVariables(this._configurationResolverService, { ...this._configHelper.config.env[platformKey] }, lastActiveWorkspaceRoot);
// const envFromShell = TerminalInstance.resolveConfigurationVariables(this._configurationResolverService, { ...this._shellLaunchConfig.env }, lastActiveWorkspaceRoot);
// this._shellLaunchConfig.env = envFromShell;
// // Merge process env with the env from config
// const parentEnv = { ...process.env };
// TerminalInstance.mergeEnvironments(parentEnv, envFromConfig);
// // Continue env initialization, merging in the env from the launch
// // config and adding keys that are needed to create the process
// const env = TerminalInstance.createTerminalEnv(parentEnv, this._shellLaunchConfig, this._initialCwd, locale, this._cols, this._rows);
// const cwd = Uri.parse(path.dirname(require.toUrl('../node/terminalProcess'))).fsPath;
// const options = { env, cwd };
// this._logService.debug(`Terminal process launching (id: ${this.id})`, options);
// this._processManager.process = cp.fork(Uri.parse(require.toUrl('bootstrap')).fsPath, ['--type=terminal'], options);
// this._processManager.processState = ProcessState.LAUNCHING;
if
(
this
.
_shellLaunchConfig
.
name
)
{
this
.
setTitle
(
this
.
_shellLaunchConfig
.
name
,
false
);
}
else
{
...
...
@@ -671,16 +613,7 @@ export class TerminalInstance implements ITerminalInstance {
};
this
.
_processManager
.
process
.
on
(
'
message
'
,
this
.
_messageTitleListener
);
}
// TODO: Move to process manager?
this
.
_processManager
.
process
.
on
(
'
message
'
,
(
message
:
ITerminalProcessMessage
)
=>
{
this
.
_processManager
.
acceptProcessMessage
(
message
);
});
this
.
_processManager
.
process
.
on
(
'
exit
'
,
exitCode
=>
this
.
_onPtyProcessExit
(
exitCode
));
setTimeout
(()
=>
{
if
(
this
.
_processManager
.
processState
===
ProcessState
.
LAUNCHING
)
{
this
.
_processManager
.
processState
=
ProcessState
.
RUNNING
;
}
},
LAUNCHING_DURATION
);
}
private
_sendPtyDataToXterm
(
message
:
{
type
:
string
,
content
:
string
}):
void
{
...
...
@@ -695,6 +628,7 @@ export class TerminalInstance implements ITerminalInstance {
}
}
// TODO: Move most to TerminalProcessManager, fire an event when it happens
private
_onPtyProcessExit
(
exitCode
:
number
):
void
{
this
.
_logService
.
debug
(
`Terminal process exit (id:
${
this
.
id
}
) with code
${
exitCode
}
`
);
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalProcessManager.ts
浏览文件 @
68160413
...
...
@@ -19,6 +19,9 @@ import { IConfigurationResolverService } from 'vs/workbench/services/configurati
import
{
IWorkspaceFolder
,
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IHistoryService
}
from
'
vs/workbench/services/history/common/history
'
;
/** The amount of time to consider terminal errors to be related to the launch */
const
LAUNCHING_DURATION
=
500
;
/**
* Holds all state related to the creation and management of terminal processes.
*
...
...
@@ -29,7 +32,6 @@ import { IHistoryService } from 'vs/workbench/services/history/common/history';
*/
export
class
TerminalProcessManager
implements
ITerminalProcessManager
{
public
processState
:
ProcessState
=
ProcessState
.
UNINITIALIZED
;
// _process
public
process
:
cp
.
ChildProcess
;
public
ptyProcessReady
:
TPromise
<
void
>
;
public
shellProcessId
:
number
;
...
...
@@ -96,6 +98,15 @@ export class TerminalProcessManager implements ITerminalProcessManager {
this
.
_logService
.
debug
(
`Terminal process launching`
,
options
);
this
.
process
=
cp
.
fork
(
Uri
.
parse
(
require
.
toUrl
(
'
bootstrap
'
)).
fsPath
,
[
'
--type=terminal
'
],
options
);
this
.
processState
=
ProcessState
.
LAUNCHING
;
// TODO: Hide message communication details inside terminal process manager
this
.
process
.
on
(
'
message
'
,
message
=>
this
.
acceptProcessMessage
(
message
));
setTimeout
(()
=>
{
if
(
this
.
processState
===
ProcessState
.
LAUNCHING
)
{
this
.
processState
=
ProcessState
.
RUNNING
;
}
},
LAUNCHING_DURATION
);
}
protected
_getCwd
(
shell
:
IShellLaunchConfig
,
root
:
Uri
):
string
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录