Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d0eaf9a7
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,发现更多精彩内容 >>
提交
d0eaf9a7
编写于
2月 13, 2018
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix NPE and ensure tab element is removed after disposal
上级
3c799314
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
24 deletion
+25
-24
src/vs/workbench/parts/terminal/common/terminalService.ts
src/vs/workbench/parts/terminal/common/terminalService.ts
+9
-14
src/vs/workbench/parts/terminal/electron-browser/terminalTab.ts
.../workbench/parts/terminal/electron-browser/terminalTab.ts
+16
-10
未找到文件。
src/vs/workbench/parts/terminal/common/terminalService.ts
浏览文件 @
d0eaf9a7
...
...
@@ -97,12 +97,10 @@ export abstract class TerminalService implements ITerminalService {
}
public
getTabLabels
():
string
[]
{
console
.
log
(
'
tabs
'
,
this
.
_terminalTabs
);
return
this
.
_terminalTabs
.
map
((
tab
,
index
)
=>
`
${
index
+
1
}
:
${
tab
.
title
}
`
);
}
private
_removeTab
(
tab
:
ITerminalTab
):
void
{
console
.
log
(
'
_removeTab
'
);
// Get the index of the tab and remove it from the list
const
index
=
this
.
_terminalTabs
.
indexOf
(
tab
);
const
wasActiveTab
=
tab
===
this
.
getActiveTab
();
...
...
@@ -112,20 +110,21 @@ export abstract class TerminalService implements ITerminalService {
// Adjust focus if the tab was active
if
(
wasActiveTab
&&
this
.
_terminalTabs
.
length
>
0
)
{
const
hasFocusOnExit
=
tab
.
activeInstance
.
hadFocusOnExit
;
// TODO: Only focus the new tab if the removed tab had focus?
// const hasFocusOnExit = tab.activeInstance.hadFocusOnExit;
let
newIndex
=
index
<
this
.
_terminalTabs
.
length
?
index
:
this
.
_terminalTabs
.
length
-
1
;
this
.
setActiveInstanceByIndex
(
newIndex
);
if
(
hasFocusOnExit
)
{
this
.
getActiveInstance
().
focus
(
true
);
}
this
.
setActiveTabByIndex
(
newIndex
);
this
.
getActiveInstance
().
focus
(
true
);
}
// Hide the panel if there are no more instances, provided that VS Code is not shutting
// down. When shutting down the panel is locked in place so that it is restored upon next
// launch.
if
(
this
.
_terminalTabs
.
length
===
0
&&
!
this
.
_isShuttingDown
)
{
this
.
hidePanel
();
}
// TODO: This should be onTabsChanged?
// Fire events
this
.
_onInstancesChanged
.
fire
();
if
(
wasActiveTab
)
{
this
.
_onActiveTabChanged
.
fire
();
...
...
@@ -193,23 +192,19 @@ export abstract class TerminalService implements ITerminalService {
return
null
;
}
// TODO: Remove setActiveInstanceByIndex?
public
setActiveInstanceByIndex
(
terminalIndex
:
number
):
void
{
const
query
=
this
.
_getInstanceFromGlobalInstanceIndex
(
terminalIndex
);
if
(
!
query
)
{
return
;
}
console
.
log
(
'
setActiveInstanceByIndex
'
,
terminalIndex
,
query
);
const
didInstanceChange
=
query
.
tab
.
setActiveInstanceByIndex
(
query
.
localInstanceIndex
);
query
.
tab
.
setActiveInstanceByIndex
(
query
.
localInstanceIndex
);
const
didTabChange
=
this
.
_activeTabIndex
!==
query
.
tabIndex
;
this
.
_activeTabIndex
=
query
.
tabIndex
;
this
.
_terminalTabs
.
forEach
((
t
,
i
)
=>
t
.
setVisible
(
i
===
query
.
tabIndex
));
// TOOD: Should this live in TerminalTab now?
// Only fire the event if there was a change
if
(
didInstanceChange
||
didTabChange
)
{
// TODO: If this method is being kept this should only fire when the _tab_ is actually changed
if
(
didTabChange
)
{
this
.
_onActiveTabChanged
.
fire
();
}
}
...
...
src/vs/workbench/parts/terminal/electron-browser/terminalTab.ts
浏览文件 @
d0eaf9a7
...
...
@@ -223,6 +223,10 @@ export class TerminalTab extends Disposable implements ITerminalTab {
public
dispose
():
void
{
super
.
dispose
();
if
(
this
.
_tabElement
)
{
this
.
_container
.
removeChild
(
this
.
_tabElement
);
this
.
_tabElement
=
null
;
}
this
.
_terminalInstances
=
[];
this
.
_onInstancesChanged
.
fire
();
}
...
...
@@ -246,18 +250,20 @@ export class TerminalTab extends Disposable implements ITerminalTab {
if
(
wasActiveInstance
&&
this
.
_terminalInstances
.
length
>
0
)
{
let
newIndex
=
index
<
this
.
_terminalInstances
.
length
?
index
:
this
.
_terminalInstances
.
length
-
1
;
this
.
setActiveInstanceByIndex
(
newIndex
);
if
(
instance
.
hadFocusOnExit
)
{
this
.
activeInstance
.
focus
(
true
);
}
// TODO: Only focus the new instance if the tab had focus?
this
.
activeInstance
.
focus
(
true
);
}
// Find the instance's SplitPane and unsplit it
this
.
_findSplitPane
(
instance
).
remove
();
const
pane
=
this
.
_findSplitPane
(
instance
);
if
(
pane
)
{
pane
.
remove
();
}
// Fire events and dispose tab if it was the last instance
this
.
_onInstancesChanged
.
fire
();
if
(
this
.
_terminalInstances
.
length
===
0
)
{
this
.
_onDisposed
.
fire
(
this
);
this
.
_onInstancesChanged
.
fire
();
this
.
dispose
();
}
}
...
...
@@ -292,18 +298,18 @@ export class TerminalTab extends Disposable implements ITerminalTab {
return
terminalIndex
;
}
public
setActiveInstanceByIndex
(
index
:
number
):
boolean
{
public
setActiveInstanceByIndex
(
index
:
number
):
void
{
// Check for invalid value
if
(
index
>=
this
.
_terminalInstances
.
length
)
{
return
false
;
return
;
}
const
didInstanceChange
=
this
.
_activeInstanceIndex
!==
index
;
this
.
_activeInstanceIndex
=
index
;
// TODO: Fire events like in TerminalService.setActiveInstanceByIndex?
return
didInstanceChange
;
if
(
didInstanceChange
)
{
this
.
_onInstancesChanged
.
fire
();
}
}
public
attachToElement
(
element
:
HTMLElement
):
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录