Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
f6bef608
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,发现更多精彩内容 >>
提交
f6bef608
编写于
11月 27, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixes #38963
上级
7e23e756
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
74 addition
and
18 deletion
+74
-18
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
+74
-18
未找到文件。
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
浏览文件 @
f6bef608
...
...
@@ -82,6 +82,10 @@ export interface IViewModel {
readonly
repositories
:
ISCMRepository
[];
readonly
selectedRepositories
:
ISCMRepository
[];
readonly
onDidSplice
:
Event
<
ISpliceEvent
<
ISCMRepository
>>
;
isVisible
():
boolean
;
readonly
onDidChangeVisibility
:
Event
<
boolean
>
;
hide
(
repository
:
ISCMRepository
):
void
;
}
...
...
@@ -212,7 +216,9 @@ class ProviderRenderer implements IRenderer<ISCMRepository, RepositoryTemplateDa
class
MainPanel
extends
ViewletPanel
{
private
list
:
List
<
ISCMRepository
>
;
private
visibilityDisposables
:
IDisposable
[]
=
[];
private
previousSelection
:
ISCMRepository
[]
|
undefined
=
undefined
;
private
_onSelectionChange
=
new
Emitter
<
ISCMRepository
[]
>
();
readonly
onSelectionChange
:
Event
<
ISCMRepository
[]
>
=
this
.
_onSelectionChange
.
event
;
...
...
@@ -252,18 +258,6 @@ class MainPanel extends ViewletPanel {
return
this
.
list
.
getSelectedElements
();
}
private
splice
(
index
:
number
,
deleteCount
:
number
,
repositories
:
ISCMRepository
[]
=
[]):
void
{
const
wasEmpty
=
this
.
list
.
length
===
0
;
this
.
list
.
splice
(
index
,
deleteCount
,
repositories
);
this
.
updateBodySize
();
// Automatically select the first one
if
(
wasEmpty
&&
this
.
list
.
length
>
0
)
{
this
.
list
.
setSelection
([
0
]);
}
}
protected
renderBody
(
container
:
HTMLElement
):
void
{
const
delegate
=
new
ProvidersListDelegate
();
const
renderer
=
this
.
instantiationService
.
createInstance
(
ProviderRenderer
);
...
...
@@ -276,8 +270,30 @@ class MainPanel extends ViewletPanel {
this
.
list
.
onSelectionChange
(
this
.
onListSelectionChange
,
this
,
this
.
disposables
);
this
.
list
.
onContextMenu
(
this
.
onListContextMenu
,
this
,
this
.
disposables
);
this
.
viewModel
.
onDidSplice
(({
index
,
deleteCount
,
elements
})
=>
this
.
splice
(
index
,
deleteCount
,
elements
),
null
,
this
.
disposables
);
this
.
splice
(
0
,
0
,
this
.
viewModel
.
repositories
);
this
.
viewModel
.
onDidChangeVisibility
(
this
.
onDidChangeVisibility
,
this
,
this
.
disposables
);
this
.
onDidChangeVisibility
(
this
.
viewModel
.
isVisible
());
}
private
onDidChangeVisibility
(
visible
:
boolean
):
void
{
if
(
visible
)
{
this
.
viewModel
.
onDidSplice
(({
index
,
deleteCount
,
elements
})
=>
this
.
splice
(
index
,
deleteCount
,
elements
),
null
,
this
.
visibilityDisposables
);
this
.
splice
(
0
,
0
,
this
.
viewModel
.
repositories
);
}
else
{
this
.
visibilityDisposables
=
dispose
(
this
.
visibilityDisposables
);
this
.
splice
(
0
,
this
.
list
.
length
);
}
}
private
splice
(
index
:
number
,
deleteCount
:
number
,
repositories
:
ISCMRepository
[]
=
[]):
void
{
const
wasEmpty
=
this
.
list
.
length
===
0
;
this
.
list
.
splice
(
index
,
deleteCount
,
repositories
);
this
.
updateBodySize
();
// Automatically select the first one
if
(
wasEmpty
&&
this
.
list
.
length
>
0
)
{
this
.
restoreSelection
();
}
}
protected
layoutBody
(
size
:
number
):
void
{
...
...
@@ -328,12 +344,32 @@ class MainPanel extends ViewletPanel {
private
onListSelectionChange
(
e
:
IListEvent
<
ISCMRepository
>
):
void
{
// select one repository if the selected one is gone
if
(
e
.
elements
.
length
===
0
&&
this
.
list
.
length
>
0
)
{
this
.
list
.
setSelection
([
0
]
);
this
.
restoreSelection
(
);
return
;
}
if
(
e
.
elements
.
length
>
0
)
{
this
.
previousSelection
=
e
.
elements
;
}
this
.
_onSelectionChange
.
fire
(
e
.
elements
);
}
private
restoreSelection
():
void
{
let
selection
:
number
[];
if
(
this
.
previousSelection
)
{
selection
=
this
.
previousSelection
.
map
(
r
=>
this
.
viewModel
.
repositories
.
indexOf
(
r
))
.
filter
(
i
=>
i
>
-
1
);
}
if
(
!
selection
||
selection
.
length
===
0
)
{
selection
=
[
0
];
}
this
.
list
.
setSelection
(
selection
);
}
}
interface
ResourceGroupTemplate
{
...
...
@@ -634,6 +670,7 @@ class ResourceGroupSplicer {
}
dispose
():
void
{
this
.
onDidSpliceGroups
({
start
:
0
,
deleteCount
:
this
.
items
.
length
,
toInsert
:
[]
});
this
.
disposables
=
dispose
(
this
.
disposables
);
}
}
...
...
@@ -646,6 +683,7 @@ export class RepositoryPanel extends ViewletPanel {
private
listContainer
:
HTMLElement
;
private
list
:
List
<
ISCMResourceGroup
|
ISCMResource
>
;
private
menus
:
SCMMenus
;
private
visibilityDisposables
:
IDisposable
[]
=
[];
constructor
(
readonly
repository
:
ISCMRepository
,
...
...
@@ -772,8 +810,17 @@ export class RepositoryPanel extends ViewletPanel {
this
.
list
.
onContextMenu
(
this
.
onListContextMenu
,
this
,
this
.
disposables
);
this
.
disposables
.
push
(
this
.
list
);
const
listSplicer
=
new
ResourceGroupSplicer
(
this
.
repository
.
provider
.
groups
,
this
.
list
);
this
.
disposables
.
push
(
listSplicer
);
this
.
viewModel
.
onDidChangeVisibility
(
this
.
onDidChangeVisibility
,
this
,
this
.
disposables
);
this
.
onDidChangeVisibility
(
this
.
viewModel
.
isVisible
());
}
private
onDidChangeVisibility
(
visible
:
boolean
):
void
{
if
(
visible
)
{
const
listSplicer
=
new
ResourceGroupSplicer
(
this
.
repository
.
provider
.
groups
,
this
.
list
);
this
.
visibilityDisposables
.
push
(
listSplicer
);
}
else
{
this
.
visibilityDisposables
=
dispose
(
this
.
visibilityDisposables
);
}
}
layoutBody
(
height
:
number
=
this
.
cachedHeight
):
void
{
...
...
@@ -879,7 +926,7 @@ export class RepositoryPanel extends ViewletPanel {
}
dispose
():
void
{
this
.
disposables
=
dispose
(
this
.
d
isposables
);
this
.
visibilityDisposables
=
dispose
(
this
.
visibilityD
isposables
);
super
.
dispose
();
}
}
...
...
@@ -912,6 +959,9 @@ export class SCMViewlet extends PanelViewlet implements IViewModel {
private
_onDidSplice
=
new
Emitter
<
ISpliceEvent
<
ISCMRepository
>>
();
readonly
onDidSplice
:
Event
<
ISpliceEvent
<
ISCMRepository
>>
=
this
.
_onDidSplice
.
event
;
private
_onDidChangeVisibility
=
new
Emitter
<
boolean
>
();
readonly
onDidChangeVisibility
:
Event
<
boolean
>
=
this
.
_onDidChangeVisibility
.
event
;
private
_height
:
number
|
undefined
=
undefined
;
get
height
():
number
|
undefined
{
return
this
.
_height
;
}
...
...
@@ -1010,6 +1060,12 @@ export class SCMViewlet extends PanelViewlet implements IViewModel {
}
}
setVisible
(
visible
:
boolean
):
TPromise
<
void
>
{
const
result
=
super
.
setVisible
(
visible
);
this
.
_onDidChangeVisibility
.
fire
(
visible
);
return
result
;
}
getOptimalWidth
():
number
{
return
400
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录