Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
a841b5f1
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,发现更多精彩内容 >>
提交
a841b5f1
编写于
2月 01, 2017
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Enable process to write to terminal before the panel exists
Fixes #12000
上级
5c64c4c6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
21 addition
and
16 deletion
+21
-16
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
...bench/parts/terminal/electron-browser/terminalInstance.ts
+19
-15
src/vs/workbench/parts/terminal/test/electron-browser/terminalInstance.test.ts
...s/terminal/test/electron-browser/terminalInstance.test.ts
+1
-0
src/vs/workbench/parts/terminal/test/electron-browser/terminalService.test.ts
...ts/terminal/test/electron-browser/terminalService.test.ts
+1
-1
未找到文件。
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
浏览文件 @
a841b5f1
...
...
@@ -97,7 +97,9 @@ export class TerminalInstance implements ITerminalInstance {
this
.
_onTitleChanged
=
new
Emitter
<
string
>
();
this
.
_createProcess
(
this
.
_contextService
.
getWorkspace
(),
this
.
_shellLaunchConfig
);
this
.
_createXterm
();
// Only attach xterm.js to the DOM if the terminal panel has been opened before.
if
(
_container
)
{
this
.
attachToElement
(
_container
);
}
...
...
@@ -107,21 +109,13 @@ export class TerminalInstance implements ITerminalInstance {
this
.
_instanceDisposables
.
push
(
disposable
);
}
public
attachToElement
(
container
:
HTMLElement
):
void
{
if
(
this
.
_wrapperElement
)
{
throw
new
Error
(
'
The terminal instance has already been attached to a container
'
);
}
this
.
_container
=
container
;
this
.
_wrapperElement
=
document
.
createElement
(
'
div
'
);
DOM
.
addClass
(
this
.
_wrapperElement
,
'
terminal-wrapper
'
);
this
.
_xtermElement
=
document
.
createElement
(
'
div
'
);
/**
* Create xterm.js instance and attach data listeners.
*/
protected
_createXterm
():
void
{
this
.
_xterm
=
xterm
({
scrollback
:
this
.
_configHelper
.
getScrollback
()
});
this
.
_xterm
.
open
(
this
.
_xtermElement
);
this
.
_process
.
on
(
'
message
'
,
(
message
)
=>
this
.
_sendPtyDataToXterm
(
message
));
this
.
_xterm
.
on
(
'
data
'
,
(
data
)
=>
{
if
(
this
.
_process
)
{
...
...
@@ -132,6 +126,19 @@ export class TerminalInstance implements ITerminalInstance {
}
return
false
;
});
}
public
attachToElement
(
container
:
HTMLElement
):
void
{
if
(
this
.
_wrapperElement
)
{
throw
new
Error
(
'
The terminal instance has already been attached to a container
'
);
}
this
.
_container
=
container
;
this
.
_wrapperElement
=
document
.
createElement
(
'
div
'
);
DOM
.
addClass
(
this
.
_wrapperElement
,
'
terminal-wrapper
'
);
this
.
_xtermElement
=
document
.
createElement
(
'
div
'
);
this
.
_xterm
.
open
(
this
.
_xtermElement
);
this
.
_xterm
.
attachCustomKeydownHandler
((
event
:
KeyboardEvent
)
=>
{
// Disable all input if the terminal is exiting
if
(
this
.
_isExiting
)
{
...
...
@@ -387,9 +394,6 @@ export class TerminalInstance implements ITerminalInstance {
}
private
_sendPtyDataToXterm
(
message
:
{
type
:
string
,
content
:
string
}):
void
{
if
(
!
this
.
_xterm
)
{
return
;
}
if
(
message
.
type
===
'
data
'
)
{
this
.
_xterm
.
write
(
message
.
content
);
}
...
...
src/vs/workbench/parts/terminal/test/electron-browser/terminalInstance.test.ts
浏览文件 @
a841b5f1
...
...
@@ -25,6 +25,7 @@ class TestTerminalInstance extends TerminalInstance {
}
protected
_createProcess
(
workspace
:
IWorkspace
,
shell
:
IShellLaunchConfig
):
void
{
}
protected
_createXterm
():
void
{
}
}
suite
(
'
Workbench - TerminalInstance
'
,
()
=>
{
...
...
src/vs/workbench/parts/terminal/test/electron-browser/terminalService.test.ts
浏览文件 @
a841b5f1
...
...
@@ -20,7 +20,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
class
TestTerminalProcessFactory
implements
ITerminalProcessFactory
{
public
create
(
env
:
{
[
key
:
string
]:
string
}):
cp
.
ChildProcess
{
return
<
any
>
{};
return
<
any
>
{
on
:
()
=>
{
}
};
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录