Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
718a0932
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,发现更多精彩内容 >>
提交
718a0932
编写于
11月 02, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
commands and widgets do not get along nicely
fixes #62458
上级
3e7f8dff
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
54 addition
and
48 deletion
+54
-48
src/vs/base/browser/ui/list/listWidget.ts
src/vs/base/browser/ui/list/listWidget.ts
+8
-8
src/vs/base/browser/ui/tree/abstractTree.ts
src/vs/base/browser/ui/tree/abstractTree.ts
+14
-14
src/vs/platform/list/browser/listService.ts
src/vs/platform/list/browser/listService.ts
+4
-0
src/vs/workbench/electron-browser/commands.ts
src/vs/workbench/electron-browser/commands.ts
+28
-26
未找到文件。
src/vs/base/browser/ui/list/listWidget.ts
浏览文件 @
718a0932
...
...
@@ -1087,7 +1087,7 @@ export class List<T> implements ISpliceable<T>, IDisposable {
if
(
this
.
length
===
0
)
{
return
;
}
const
focus
=
this
.
focus
.
get
();
let
index
=
focus
.
length
>
0
?
focus
[
0
]
+
n
:
0
;
this
.
setFocus
(
loop
?
[
index
%
this
.
length
]
:
[
Math
.
min
(
index
,
this
.
length
-
1
)]);
this
.
setFocus
(
loop
?
[
index
%
this
.
length
]
:
[
Math
.
min
(
index
,
this
.
length
-
1
)]
,
browserEvent
);
}
focusPrevious
(
n
=
1
,
loop
=
false
,
browserEvent
?:
UIEvent
):
void
{
...
...
@@ -1095,7 +1095,7 @@ export class List<T> implements ISpliceable<T>, IDisposable {
const
focus
=
this
.
focus
.
get
();
let
index
=
focus
.
length
>
0
?
focus
[
0
]
-
n
:
0
;
if
(
loop
&&
index
<
0
)
{
index
=
(
this
.
length
+
(
index
%
this
.
length
))
%
this
.
length
;
}
this
.
setFocus
([
Math
.
max
(
index
,
0
)]);
this
.
setFocus
([
Math
.
max
(
index
,
0
)]
,
browserEvent
);
}
focusNextPage
(
browserEvent
?:
UIEvent
):
void
{
...
...
@@ -1105,14 +1105,14 @@ export class List<T> implements ISpliceable<T>, IDisposable {
const
currentlyFocusedElement
=
this
.
getFocusedElements
()[
0
];
if
(
currentlyFocusedElement
!==
lastPageElement
)
{
this
.
setFocus
([
lastPageIndex
]);
this
.
setFocus
([
lastPageIndex
]
,
browserEvent
);
}
else
{
const
previousScrollTop
=
this
.
view
.
getScrollTop
();
this
.
view
.
setScrollTop
(
previousScrollTop
+
this
.
view
.
renderHeight
-
this
.
view
.
elementHeight
(
lastPageIndex
));
if
(
this
.
view
.
getScrollTop
()
!==
previousScrollTop
)
{
// Let the scroll event listener run
setTimeout
(()
=>
this
.
focusNextPage
(),
0
);
setTimeout
(()
=>
this
.
focusNextPage
(
browserEvent
),
0
);
}
}
}
...
...
@@ -1131,26 +1131,26 @@ export class List<T> implements ISpliceable<T>, IDisposable {
const
currentlyFocusedElement
=
this
.
getFocusedElements
()[
0
];
if
(
currentlyFocusedElement
!==
firstPageElement
)
{
this
.
setFocus
([
firstPageIndex
]);
this
.
setFocus
([
firstPageIndex
]
,
browserEvent
);
}
else
{
const
previousScrollTop
=
scrollTop
;
this
.
view
.
setScrollTop
(
scrollTop
-
this
.
view
.
renderHeight
);
if
(
this
.
view
.
getScrollTop
()
!==
previousScrollTop
)
{
// Let the scroll event listener run
setTimeout
(()
=>
this
.
focusPreviousPage
(),
0
);
setTimeout
(()
=>
this
.
focusPreviousPage
(
browserEvent
),
0
);
}
}
}
focusLast
(
browserEvent
?:
UIEvent
):
void
{
if
(
this
.
length
===
0
)
{
return
;
}
this
.
setFocus
([
this
.
length
-
1
]);
this
.
setFocus
([
this
.
length
-
1
]
,
browserEvent
);
}
focusFirst
(
browserEvent
?:
UIEvent
):
void
{
if
(
this
.
length
===
0
)
{
return
;
}
this
.
setFocus
([
0
]);
this
.
setFocus
([
0
]
,
browserEvent
);
}
getFocus
():
number
[]
{
...
...
src/vs/base/browser/ui/tree/abstractTree.ts
浏览文件 @
718a0932
...
...
@@ -302,33 +302,33 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
return
nodes
.
map
(
n
=>
n
.
element
);
}
setFocus
(
elements
:
TRef
[]):
void
{
setFocus
(
elements
:
TRef
[]
,
browserEvent
?:
UIEvent
):
void
{
const
indexes
=
elements
.
map
(
e
=>
this
.
model
.
getListIndex
(
e
));
this
.
view
.
setFocus
(
indexes
);
this
.
view
.
setFocus
(
indexes
,
browserEvent
);
}
focusNext
(
n
=
1
,
loop
=
false
):
void
{
this
.
view
.
focusNext
(
n
,
loop
);
focusNext
(
n
=
1
,
loop
=
false
,
browserEvent
?:
UIEvent
):
void
{
this
.
view
.
focusNext
(
n
,
loop
,
browserEvent
);
}
focusPrevious
(
n
=
1
,
loop
=
false
):
void
{
this
.
view
.
focusPrevious
(
n
,
loop
);
focusPrevious
(
n
=
1
,
loop
=
false
,
browserEvent
?:
UIEvent
):
void
{
this
.
view
.
focusPrevious
(
n
,
loop
,
browserEvent
);
}
focusNextPage
():
void
{
this
.
view
.
focusNextPage
();
focusNextPage
(
browserEvent
?:
UIEvent
):
void
{
this
.
view
.
focusNextPage
(
browserEvent
);
}
focusPreviousPage
():
void
{
this
.
view
.
focusPreviousPage
();
focusPreviousPage
(
browserEvent
?:
UIEvent
):
void
{
this
.
view
.
focusPreviousPage
(
browserEvent
);
}
focusLast
():
void
{
this
.
view
.
focusLast
();
focusLast
(
browserEvent
?:
UIEvent
):
void
{
this
.
view
.
focusLast
(
browserEvent
);
}
focusFirst
():
void
{
this
.
view
.
focusFirst
();
focusFirst
(
browserEvent
?:
UIEvent
):
void
{
this
.
view
.
focusFirst
(
browserEvent
);
}
getFocus
():
T
[]
{
...
...
src/vs/platform/list/browser/listService.ts
浏览文件 @
718a0932
...
...
@@ -598,6 +598,10 @@ export class ObjectTreeResourceNavigator<T, TFilterData> extends Disposable {
const
focus
=
this
.
tree
.
getFocus
();
this
.
tree
.
setSelection
(
focus
,
e
.
browserEvent
);
if
(
!
e
.
browserEvent
)
{
return
;
}
const
isMouseEvent
=
e
.
browserEvent
&&
e
.
browserEvent
instanceof
MouseEvent
;
if
(
!
isMouseEvent
)
{
...
...
src/vs/workbench/electron-browser/commands.ts
浏览文件 @
718a0932
...
...
@@ -61,7 +61,9 @@ export function registerCommands(): void {
else
if
(
focused
instanceof
ObjectTree
)
{
const
list
=
focused
;
list
.
focusNext
(
count
);
const
fakeKeyboardEvent
=
new
KeyboardEvent
(
'
keydown
'
);
list
.
focusNext
(
count
,
false
,
fakeKeyboardEvent
);
const
listFocus
=
list
.
getFocus
();
if
(
listFocus
.
length
)
{
list
.
reveal
(
listFocus
[
0
]);
...
...
@@ -110,10 +112,12 @@ export function registerCommands(): void {
const
focus
=
list
.
getFocus
()
?
list
.
getFocus
()[
0
]
:
void
0
;
const
selection
=
list
.
getSelection
();
const
fakeKeyboardEvent
=
new
KeyboardEvent
(
'
keydown
'
);
if
(
selection
&&
selection
.
indexOf
(
focus
)
>=
0
)
{
list
.
setSelection
(
selection
.
filter
(
s
=>
s
!==
previousFocus
));
list
.
setSelection
(
selection
.
filter
(
s
=>
s
!==
previousFocus
)
,
fakeKeyboardEvent
);
}
else
{
list
.
setSelection
(
selection
.
concat
(
focus
));
list
.
setSelection
(
selection
.
concat
(
focus
)
,
fakeKeyboardEvent
);
}
}
...
...
@@ -140,19 +144,7 @@ export function registerCommands(): void {
const
focused
=
accessor
.
get
(
IListService
).
lastFocusedList
;
// List
if
(
focused
instanceof
List
||
focused
instanceof
PagedList
)
{
const
list
=
focused
;
// Focus down first
const
previousFocus
=
list
.
getFocus
()
?
list
.
getFocus
()[
0
]
:
void
0
;
focusDown
(
accessor
,
arg2
);
// Then adjust selection
expandMultiSelection
(
focused
,
previousFocus
);
}
// ObjectTree
else
if
(
focused
instanceof
ObjectTree
)
{
if
(
focused
instanceof
List
||
focused
instanceof
PagedList
||
focused
instanceof
ObjectTree
)
{
const
list
=
focused
;
// Focus down first
...
...
@@ -199,7 +191,9 @@ export function registerCommands(): void {
else
if
(
focused
instanceof
ObjectTree
)
{
const
list
=
focused
;
list
.
focusPrevious
(
count
);
const
fakeKeyboardEvent
=
new
KeyboardEvent
(
'
keydown
'
);
list
.
focusPrevious
(
count
,
false
,
fakeKeyboardEvent
);
const
listFocus
=
list
.
getFocus
();
if
(
listFocus
.
length
)
{
list
.
reveal
(
listFocus
[
0
]);
...
...
@@ -289,7 +283,8 @@ export function registerCommands(): void {
const
parent
=
tree
.
getParentElement
(
focus
);
if
(
parent
)
{
tree
.
setFocus
([
parent
]);
const
fakeKeyboardEvent
=
new
KeyboardEvent
(
'
keydown
'
);
tree
.
setFocus
([
parent
],
fakeKeyboardEvent
);
tree
.
reveal
(
parent
);
}
}
...
...
@@ -335,7 +330,8 @@ export function registerCommands(): void {
const
child
=
tree
.
getFirstElementChild
(
focus
);
if
(
child
)
{
tree
.
setFocus
([
child
]);
const
fakeKeyboardEvent
=
new
KeyboardEvent
(
'
keydown
'
);
tree
.
setFocus
([
child
],
fakeKeyboardEvent
);
tree
.
reveal
(
child
);
}
}
...
...
@@ -380,7 +376,8 @@ export function registerCommands(): void {
else
if
(
focused
instanceof
ObjectTree
)
{
const
list
=
focused
;
list
.
focusPreviousPage
();
const
fakeKeyboardEvent
=
new
KeyboardEvent
(
'
keydown
'
);
list
.
focusPreviousPage
(
fakeKeyboardEvent
);
list
.
reveal
(
list
.
getFocus
()[
0
]);
}
...
...
@@ -417,7 +414,8 @@ export function registerCommands(): void {
else
if
(
focused
instanceof
ObjectTree
)
{
const
list
=
focused
;
list
.
focusNextPage
();
const
fakeKeyboardEvent
=
new
KeyboardEvent
(
'
keydown
'
);
list
.
focusNextPage
(
fakeKeyboardEvent
);
list
.
reveal
(
list
.
getFocus
()[
0
]);
}
...
...
@@ -470,7 +468,8 @@ export function registerCommands(): void {
return
;
}
list
.
setFocus
([
first
]);
const
fakeKeyboardEvent
=
new
KeyboardEvent
(
'
keydown
'
);
list
.
setFocus
([
first
],
fakeKeyboardEvent
);
list
.
reveal
(
first
);
}
...
...
@@ -522,7 +521,8 @@ export function registerCommands(): void {
return
;
}
list
.
setFocus
([
last
]);
const
fakeKeyboardEvent
=
new
KeyboardEvent
(
'
keydown
'
);
list
.
setFocus
([
last
],
fakeKeyboardEvent
);
list
.
reveal
(
last
);
}
...
...
@@ -557,7 +557,8 @@ export function registerCommands(): void {
// ObjectTree
else
if
(
focused
instanceof
ObjectTree
)
{
const
list
=
focused
;
list
.
setSelection
(
list
.
getFocus
());
const
fakeKeyboardEvent
=
new
KeyboardEvent
(
'
keydown
'
);
list
.
setSelection
(
list
.
getFocus
(),
fakeKeyboardEvent
);
list
.
open
(
list
.
getFocus
());
}
...
...
@@ -642,11 +643,12 @@ export function registerCommands(): void {
// ObjectTree
else
if
(
focused
instanceof
ObjectTree
)
{
const
list
=
focused
;
const
fakeKeyboardEvent
=
new
KeyboardEvent
(
'
keydown
'
);
if
(
list
.
getSelection
().
length
>
0
)
{
list
.
setSelection
([]);
list
.
setSelection
([]
,
fakeKeyboardEvent
);
}
else
if
(
list
.
getFocus
().
length
>
0
)
{
list
.
setFocus
([]);
list
.
setFocus
([]
,
fakeKeyboardEvent
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录