Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
4da71de4
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,发现更多精彩内容 >>
提交
4da71de4
编写于
2月 09, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
better way of finding out active list (for #11517)
上级
4617cb7f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
53 addition
and
22 deletion
+53
-22
src/vs/base/browser/ui/list/listWidget.ts
src/vs/base/browser/ui/list/listWidget.ts
+5
-1
src/vs/base/parts/tree/browser/treeImpl.ts
src/vs/base/parts/tree/browser/treeImpl.ts
+1
-1
src/vs/base/parts/tree/browser/treeView.ts
src/vs/base/parts/tree/browser/treeView.ts
+1
-1
src/vs/platform/list/browser/listService.ts
src/vs/platform/list/browser/listService.ts
+38
-15
src/vs/workbench/parts/files/browser/views/explorerView.ts
src/vs/workbench/parts/files/browser/views/explorerView.ts
+4
-2
src/vs/workbench/parts/files/browser/views/openEditorsView.ts
...vs/workbench/parts/files/browser/views/openEditorsView.ts
+4
-2
未找到文件。
src/vs/base/browser/ui/list/listWidget.ts
浏览文件 @
4da71de4
...
...
@@ -286,7 +286,7 @@ export class List<T> implements IDisposable {
this
.
disposables
=
[
this
.
focus
,
this
.
selection
,
this
.
view
,
this
.
_onDispose
];
const
tracker
=
DOM
.
trackFocus
(
this
.
view
.
domNode
);
this
.
disposables
.
push
(
tracker
.
addFocusListener
(()
=>
setTimeout
(()
=>
this
.
_onDOMFocus
.
fire
()
)));
this
.
disposables
.
push
(
tracker
.
addFocusListener
(()
=>
this
.
_onDOMFocus
.
fire
(
)));
this
.
disposables
.
push
(
tracker
.
addBlurListener
(()
=>
this
.
_onDOMBlur
.
fire
()));
if
(
typeof
options
.
keyboardSupport
!==
'
boolean
'
||
options
.
keyboardSupport
)
{
...
...
@@ -469,6 +469,10 @@ export class List<T> implements IDisposable {
return
this
.
view
.
domNode
===
document
.
activeElement
;
}
getHTMLElement
():
HTMLElement
{
return
this
.
view
.
domNode
;
}
private
toListEvent
({
indexes
}:
ITraitChangeEvent
)
{
return
{
indexes
,
elements
:
indexes
.
map
(
i
=>
this
.
view
.
element
(
i
))
};
}
...
...
src/vs/base/parts/tree/browser/treeImpl.ts
浏览文件 @
4da71de4
...
...
@@ -93,7 +93,7 @@ export class Tree extends Events.EventEmitter implements _.ITree {
this
.
addEmitter2
(
this
.
model
);
this
.
addEmitter2
(
this
.
view
);
this
.
toDispose
.
push
(
this
.
model
.
addListener2
(
'
highlight
'
,
()
=>
setTimeout
(()
=>
this
.
_onHighlightChange
.
fire
()
)));
this
.
toDispose
.
push
(
this
.
model
.
addListener2
(
'
highlight
'
,
()
=>
this
.
_onHighlightChange
.
fire
(
)));
}
get
onDOMFocus
():
Event
<
void
>
{
...
...
src/vs/base/parts/tree/browser/treeView.ts
浏览文件 @
4da71de4
...
...
@@ -1523,7 +1523,7 @@ export class TreeView extends HeightMap {
DOM
.
addClass
(
this
.
domNode
,
'
focused
'
);
}
setTimeout
(()
=>
this
.
_onDOMFocus
.
fire
()
);
this
.
_onDOMFocus
.
fire
(
);
}
private
onBlur
():
void
{
...
...
src/vs/platform/list/browser/listService.ts
浏览文件 @
4da71de4
...
...
@@ -9,6 +9,7 @@ import { List } from 'vs/base/browser/ui/list/listWidget';
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IContextKeyService
,
IContextKey
,
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
export
const
IListService
=
createDecorator
<
IListService
>
(
'
listService
'
);
...
...
@@ -29,53 +30,75 @@ export class ListService implements IListService {
public
_serviceBrand
:
any
;
private
focusedTreeOrList
:
ITree
|
List
<
any
>
;
private
lists
:
(
ITree
|
List
<
any
>
)[];
private
listFocusContext
:
IContextKey
<
boolean
>
;
private
focusChangeScheduler
:
RunOnceScheduler
;
constructor
(
@
IContextKeyService
contextKeyService
:
IContextKeyService
)
{
this
.
listFocusContext
=
ListFocusContext
.
bindTo
(
contextKeyService
);
this
.
lists
=
[];
this
.
focusChangeScheduler
=
new
RunOnceScheduler
(()
=>
this
.
onFocusChange
(),
50
/* delay until the focus/blur dust settles */
);
}
public
register
(
tree
:
ITree
):
IDisposable
;
public
register
(
list
:
List
<
any
>
):
IDisposable
;
public
register
(
widget
:
ITree
|
List
<
any
>
):
IDisposable
{
if
(
this
.
lists
.
indexOf
(
widget
)
>=
0
)
{
throw
new
Error
(
'
Cannot register the same widget multiple times
'
);
}
// Keep in our lists list
this
.
lists
.
push
(
widget
);
// Check for currently being focused
if
(
widget
.
isDOMFocused
())
{
this
.
onListDOMFocus
(
widget
);
this
.
setFocusedList
(
widget
);
}
const
toDispose
=
[
widget
.
onDOMFocus
(()
=>
this
.
onListDOMFocus
(
widget
)),
widget
.
onDOMBlur
(()
=>
this
.
onListDOMBlur
(
widget
))
widget
.
onDOMFocus
(()
=>
this
.
focusChangeScheduler
.
schedule
(
)),
widget
.
onDOMBlur
(()
=>
this
.
focusChangeScheduler
.
schedule
(
))
];
// Special treatment for tree highlight mode
if
(
!
(
widget
instanceof
List
))
{
toDispose
.
push
(
widget
.
onHighlightChange
(()
=>
{
if
(
this
.
focusedTreeOrList
===
widget
&&
widget
.
getHighlight
())
{
this
.
onListDOMBlur
(
widget
);
}
else
if
(
widget
.
isDOMFocused
())
{
this
.
onListDOMFocus
(
widget
);
}
const
tree
=
widget
;
toDispose
.
push
(
tree
.
onHighlightChange
(()
=>
{
this
.
focusChangeScheduler
.
schedule
();
}));
}
// Remove list once disposed
toDispose
.
push
({
dispose
:
()
=>
{
this
.
lists
.
splice
(
this
.
lists
.
indexOf
(
widget
),
1
);
}
});
return
{
dispose
:
()
=>
dispose
(
toDispose
)
};
}
private
onListDOMFocus
(
list
:
ITree
|
List
<
any
>
):
void
{
this
.
focusedTreeOrList
=
list
;
this
.
listFocusContext
.
set
(
true
);
private
onFocusChange
():
void
{
let
focusedList
:
ITree
|
List
<
any
>
;
for
(
let
i
=
0
;
i
<
this
.
lists
.
length
;
i
++
)
{
const
list
=
this
.
lists
[
i
];
if
(
document
.
activeElement
===
list
.
getHTMLElement
())
{
focusedList
=
list
;
break
;
}
}
this
.
setFocusedList
(
focusedList
);
}
private
onListDOMBlur
(
l
ist
:
ITree
|
List
<
any
>
):
void
{
this
.
focusedTreeOrList
=
void
0
;
this
.
listFocusContext
.
set
(
false
);
private
setFocusedList
(
focusedL
ist
:
ITree
|
List
<
any
>
):
void
{
this
.
focusedTreeOrList
=
focusedList
;
this
.
listFocusContext
.
set
(
!!
focusedList
);
}
public
getFocused
():
ITree
|
List
<
any
>
{
...
...
src/vs/workbench/parts/files/browser/views/explorerView.ts
浏览文件 @
4da71de4
...
...
@@ -370,8 +370,10 @@ export class ExplorerView extends CollapsibleViewletView {
// Update explorer focus context
this
.
toDispose
.
push
(
this
.
explorerViewer
.
onDOMFocus
(()
=>
{
this
.
filesExplorerFocussedContext
.
set
(
true
);
this
.
explorerFocussedContext
.
set
(
true
);
setTimeout
(()
=>
{
this
.
filesExplorerFocussedContext
.
set
(
true
);
this
.
explorerFocussedContext
.
set
(
true
);
},
0
/* helps when focus jumps from one tree to another */
);
}));
this
.
toDispose
.
push
(
this
.
explorerViewer
.
onDOMBlur
(()
=>
{
...
...
src/vs/workbench/parts/files/browser/views/openEditorsView.ts
浏览文件 @
4da71de4
...
...
@@ -126,8 +126,10 @@ export class OpenEditorsView extends AdaptiveCollapsibleViewletView {
// Update open editors focus context
this
.
toDispose
.
push
(
this
.
tree
.
onDOMFocus
(()
=>
{
this
.
openEditorsFocussedContext
.
set
(
true
);
this
.
explorerFocussedContext
.
set
(
true
);
setTimeout
(()
=>
{
this
.
openEditorsFocussedContext
.
set
(
true
);
this
.
explorerFocussedContext
.
set
(
true
);
},
0
/* helps when focus jumps from one tree to another */
);
}));
this
.
toDispose
.
push
(
this
.
tree
.
onDOMBlur
(()
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录