Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
b9a0aeef
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b9a0aeef
编写于
4月 13, 2018
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Introduce TerminalProcessManager
上级
2e6a761f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
86 addition
and
7 deletion
+86
-7
src/vs/workbench/parts/terminal/common/terminal.ts
src/vs/workbench/parts/terminal/common/terminal.ts
+4
-0
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
...bench/parts/terminal/electron-browser/terminalInstance.ts
+15
-7
src/vs/workbench/parts/terminal/electron-browser/terminalProcessManager.ts
...parts/terminal/electron-browser/terminalProcessManager.ts
+67
-0
未找到文件。
src/vs/workbench/parts/terminal/common/terminal.ts
浏览文件 @
b9a0aeef
...
...
@@ -456,3 +456,7 @@ export interface ITerminalCommandTracker {
selectToPreviousCommand
():
void
;
selectToNextCommand
():
void
;
}
export
interface
ITerminalProcessManager
extends
IDisposable
{
addDisposable
(
disposable
:
IDisposable
);
}
\ No newline at end of file
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
浏览文件 @
b9a0aeef
...
...
@@ -18,7 +18,7 @@ import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/c
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IPanelService
}
from
'
vs/workbench/services/panel/common/panelService
'
;
import
{
IStringDictionary
}
from
'
vs/base/common/collections
'
;
import
{
ITerminalInstance
,
KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED
,
TERMINAL_PANEL_ID
,
IShellLaunchConfig
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
import
{
ITerminalInstance
,
KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED
,
TERMINAL_PANEL_ID
,
IShellLaunchConfig
,
ITerminalProcessManager
}
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
'
;
...
...
@@ -40,6 +40,7 @@ import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
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
;
...
...
@@ -71,6 +72,8 @@ export class TerminalInstance implements ITerminalInstance {
private
static
_lastKnownDimensions
:
dom
.
Dimension
=
null
;
private
static
_idCounter
=
1
;
private
_processManager
:
ITerminalProcessManager
|
undefined
;
private
_id
:
number
;
private
_isExiting
:
boolean
;
private
_hadFocusOnExit
:
boolean
;
...
...
@@ -86,8 +89,9 @@ export class TerminalInstance implements ITerminalInstance {
private
_processId
:
number
;
private
_skipTerminalCommands
:
string
[];
private
_title
:
string
;
// TODO: Rename to "_disposables"
private
_instanceDisposables
:
lifecycle
.
IDisposable
[];
private
_processDisposables
:
lifecycle
.
IDisposable
[];
//
private _processDisposables: lifecycle.IDisposable[];
private
_wrapperElement
:
HTMLDivElement
;
private
_xterm
:
XTermTerminal
;
private
_xtermElement
:
HTMLDivElement
;
...
...
@@ -139,7 +143,6 @@ export class TerminalInstance implements ITerminalInstance {
@
ILogService
private
_logService
:
ILogService
)
{
this
.
_instanceDisposables
=
[];
this
.
_processDisposables
=
[];
this
.
_skipTerminalCommands
=
[];
this
.
_onLineDataListeners
=
[];
this
.
_isExiting
=
false
;
...
...
@@ -562,7 +565,7 @@ export class TerminalInstance implements ITerminalInstance {
this
.
_isDisposed
=
true
;
this
.
_onDisposed
.
fire
(
this
);
}
this
.
_process
Disposables
=
lifecycle
.
dispose
(
this
.
_processDisposables
);
this
.
_process
Manager
.
dispose
(
);
this
.
_instanceDisposables
=
lifecycle
.
dispose
(
this
.
_instanceDisposables
);
}
...
...
@@ -683,6 +686,9 @@ export class TerminalInstance implements ITerminalInstance {
}
protected
_createProcess
():
void
{
// TODO: This should be injected in to the terminal instance (from service?)
this
.
_processManager
=
new
TerminalProcessManager
();
const
locale
=
this
.
_configHelper
.
config
.
setLocaleVariables
?
platform
.
locale
:
undefined
;
if
(
!
this
.
_shellLaunchConfig
.
executable
)
{
this
.
_configHelper
.
mergeDefaultShellPathAndArgs
(
this
.
_shellLaunchConfig
);
...
...
@@ -845,7 +851,7 @@ export class TerminalInstance implements ITerminalInstance {
}
private
_attachPressAnyKeyToCloseListener
()
{
this
.
_process
Disposables
.
push
(
dom
.
addDisposableListener
(
this
.
_xterm
.
textarea
,
'
keypress
'
,
(
event
:
KeyboardEvent
)
=>
{
this
.
_process
Manager
.
addDisposable
(
dom
.
addDisposableListener
(
this
.
_xterm
.
textarea
,
'
keypress
'
,
(
event
:
KeyboardEvent
)
=>
{
this
.
dispose
();
event
.
preventDefault
();
}));
...
...
@@ -860,8 +866,10 @@ export class TerminalInstance implements ITerminalInstance {
}
this
.
_process
=
null
;
}
lifecycle
.
dispose
(
this
.
_processDisposables
);
this
.
_processDisposables
=
[];
// TODO: This should not call dispose directly, process manager should dispose any
// disposables when creating a new process
this
.
_processManager
.
dispose
();
// Ensure new processes' output starts at start of new line
this
.
_xterm
.
write
(
'
\n\
x1b[G
'
);
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalProcessManager.ts
0 → 100644
浏览文件 @
b9a0aeef
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
cp
from
'
child_process
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ITerminalProcessManager
}
from
'
../common/terminal
'
;
export
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
}
/**
* Holds all state related to the creation and management of terminal processes.
*
* Definitions:
* - Terminal Process: The process launched with the terminalProcess.ts file
* - Pty Process: The pseudoterminal slave process (or the winpty agent process)
* - Shell Process: The pseudoterminal master process
*/
export
class
TerminalProcessManager
implements
ITerminalProcessManager
{
// _processState
// public _terminalProcessState: ProcessState;
// _process
// private _terminalProcess: cp.ChildProcess;
// private _terminalProcessReady: TPromise<void>;
// private _shellProcessId: number;
private
_disposables
:
IDisposable
[]
=
[];
constructor
()
{
}
public
dispose
():
void
{
this
.
_disposables
.
forEach
(
d
=>
d
.
dispose
());
this
.
_disposables
.
length
=
0
;
}
public
addDisposable
(
disposable
:
IDisposable
)
{
this
.
_disposables
.
push
(
disposable
);
}
// Should this be here or in instance?
// private _isExiting: boolean;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录