Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
b63cd542
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,发现更多精彩内容 >>
提交
b63cd542
编写于
3月 29, 2017
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #23395
上级
a9544249
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
21 addition
and
20 deletion
+21
-20
src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts
.../workbench/parts/preferences/browser/keybindingsEditor.ts
+21
-20
未找到文件。
src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts
浏览文件 @
b63cd542
...
@@ -149,7 +149,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
...
@@ -149,7 +149,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
focus
():
void
{
focus
():
void
{
const
activeKeybindingEntry
=
this
.
activeKeybindingEntry
;
const
activeKeybindingEntry
=
this
.
activeKeybindingEntry
;
if
(
activeKeybindingEntry
)
{
if
(
activeKeybindingEntry
)
{
this
.
focus
Entry
(
activeKeybindingEntry
);
this
.
select
Entry
(
activeKeybindingEntry
);
}
else
{
}
else
{
this
.
searchWidget
.
focus
();
this
.
searchWidget
.
focus
();
}
}
...
@@ -161,6 +161,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
...
@@ -161,6 +161,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
}
}
defineKeybinding
(
keybindingEntry
:
IKeybindingItemEntry
):
TPromise
<
any
>
{
defineKeybinding
(
keybindingEntry
:
IKeybindingItemEntry
):
TPromise
<
any
>
{
this
.
selectEntry
(
keybindingEntry
);
this
.
showOverlayContainer
();
this
.
showOverlayContainer
();
return
this
.
defineKeybindingWidget
.
define
().
then
(
key
=>
{
return
this
.
defineKeybindingWidget
.
define
().
then
(
key
=>
{
if
(
key
)
{
if
(
key
)
{
...
@@ -174,40 +175,43 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
...
@@ -174,40 +175,43 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
return
null
;
return
null
;
}).
then
(()
=>
{
}).
then
(()
=>
{
this
.
hideOverlayContainer
();
this
.
hideOverlayContainer
();
this
.
focus
Entry
(
keybindingEntry
);
this
.
select
Entry
(
keybindingEntry
);
},
error
=>
{
},
error
=>
{
this
.
hideOverlayContainer
();
this
.
hideOverlayContainer
();
this
.
onKeybindingEditingError
(
error
);
this
.
onKeybindingEditingError
(
error
);
this
.
focus
Entry
(
keybindingEntry
);
this
.
select
Entry
(
keybindingEntry
);
return
error
;
return
error
;
});
});
}
}
removeKeybinding
(
keybindingEntry
:
IKeybindingItemEntry
):
TPromise
<
any
>
{
removeKeybinding
(
keybindingEntry
:
IKeybindingItemEntry
):
TPromise
<
any
>
{
this
.
selectEntry
(
keybindingEntry
);
if
(
keybindingEntry
.
keybindingItem
.
keybinding
)
{
// This should be a pre-condition
if
(
keybindingEntry
.
keybindingItem
.
keybinding
)
{
// This should be a pre-condition
return
this
.
keybindingEditingService
.
removeKeybinding
(
keybindingEntry
.
keybindingItem
.
keybindingItem
)
return
this
.
keybindingEditingService
.
removeKeybinding
(
keybindingEntry
.
keybindingItem
.
keybindingItem
)
.
then
(()
=>
this
.
focus
(),
.
then
(()
=>
this
.
focus
(),
error
=>
{
error
=>
{
this
.
onKeybindingEditingError
(
error
);
this
.
onKeybindingEditingError
(
error
);
this
.
focus
Entry
(
keybindingEntry
);
this
.
select
Entry
(
keybindingEntry
);
});
});
}
}
return
TPromise
.
as
(
null
);
return
TPromise
.
as
(
null
);
}
}
resetKeybinding
(
keybindingEntry
:
IKeybindingItemEntry
):
TPromise
<
any
>
{
resetKeybinding
(
keybindingEntry
:
IKeybindingItemEntry
):
TPromise
<
any
>
{
this
.
selectEntry
(
keybindingEntry
);
if
(
keybindingEntry
.
keybindingItem
.
keybinding
)
{
// This should be a pre-condition
if
(
keybindingEntry
.
keybindingItem
.
keybinding
)
{
// This should be a pre-condition
return
this
.
keybindingEditingService
.
resetKeybinding
(
keybindingEntry
.
keybindingItem
.
keybindingItem
)
return
this
.
keybindingEditingService
.
resetKeybinding
(
keybindingEntry
.
keybindingItem
.
keybindingItem
)
.
then
(()
=>
this
.
focus
(),
.
then
(()
=>
this
.
focus
(),
error
=>
{
error
=>
{
this
.
onKeybindingEditingError
(
error
);
this
.
onKeybindingEditingError
(
error
);
this
.
focus
Entry
(
keybindingEntry
);
this
.
select
Entry
(
keybindingEntry
);
});
});
}
}
return
TPromise
.
as
(
null
);
return
TPromise
.
as
(
null
);
}
}
copyKeybinding
(
keybinding
:
IKeybindingItemEntry
):
TPromise
<
any
>
{
copyKeybinding
(
keybinding
:
IKeybindingItemEntry
):
TPromise
<
any
>
{
this
.
selectEntry
(
keybinding
);
const
userFriendlyKeybinding
:
IUserFriendlyKeybinding
=
{
const
userFriendlyKeybinding
:
IUserFriendlyKeybinding
=
{
command
:
keybinding
.
keybindingItem
.
command
,
command
:
keybinding
.
keybindingItem
.
command
,
key
:
keybinding
.
keybindingItem
.
keybinding
?
keybinding
.
keybindingItem
.
keybinding
.
getUserSettingsLabel
()
:
''
key
:
keybinding
.
keybindingItem
.
keybinding
?
keybinding
.
keybindingItem
.
keybinding
.
getUserSettingsLabel
()
:
''
...
@@ -279,10 +283,10 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
...
@@ -279,10 +283,10 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
private
createList
(
parent
:
HTMLElement
):
void
{
private
createList
(
parent
:
HTMLElement
):
void
{
this
.
keybindingsListContainer
=
DOM
.
append
(
parent
,
$
(
'
.keybindings-list-container
'
));
this
.
keybindingsListContainer
=
DOM
.
append
(
parent
,
$
(
'
.keybindings-list-container
'
));
this
.
keybindingsList
=
this
.
_register
(
new
List
<
IListEntry
>
(
this
.
keybindingsListContainer
,
new
Delegate
(),
[
new
KeybindingHeaderRenderer
(),
new
KeybindingItemRenderer
(
this
,
this
.
keybindingsService
)],
{
identityProvider
:
e
=>
e
.
id
}));
this
.
keybindingsList
=
this
.
_register
(
new
List
<
IListEntry
>
(
this
.
keybindingsListContainer
,
new
Delegate
(),
[
new
KeybindingHeaderRenderer
(),
new
KeybindingItemRenderer
(
this
,
this
.
keybindingsService
)],
{
identityProvider
:
e
=>
e
.
id
,
keyboardSupport
:
true
,
mouseSupport
:
true
,
ariaLabel
:
localize
(
'
keybindingsLabel
'
,
"
Keybindings
"
)
}));
this
.
_register
(
this
.
keybindingsList
.
onContextMenu
(
e
=>
this
.
onContextMenu
(
e
)));
this
.
_register
(
this
.
keybindingsList
.
onContextMenu
(
e
=>
this
.
onContextMenu
(
e
)));
this
.
_register
(
this
.
keybindingsList
.
onFocusChange
(
e
=>
this
.
onFocusChange
(
e
)));
this
.
_register
(
this
.
keybindingsList
.
onFocusChange
(
e
=>
this
.
onFocusChange
(
e
)));
this
.
_register
(
this
.
keybindingsList
.
onDOMFocus
(()
=>
this
.
onKeybindingsListDOMFocus
()));
this
.
_register
(
this
.
keybindingsList
.
onDOMBlur
(()
=>
this
.
keybindingFocusContextKey
.
reset
()));
this
.
_register
(
this
.
keybindingsList
.
onDOMBlur
(()
=>
this
.
keybindingFocusContextKey
.
reset
()));
this
.
_register
(
this
.
listService
.
register
(
this
.
keybindingsList
));
this
.
_register
(
this
.
listService
.
register
(
this
.
keybindingsList
));
...
@@ -298,7 +302,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
...
@@ -298,7 +302,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
}
}
private
renderKeybindingsEntries
(
keybindingsEntries
:
IKeybindingItemEntry
[]):
void
{
private
renderKeybindingsEntries
(
keybindingsEntries
:
IKeybindingItemEntry
[]):
void
{
const
current
FocussedIndex
=
this
.
keybindingsList
.
getFocus
()[
0
];
const
current
SelectedIndex
=
this
.
keybindingsList
.
getSelection
()[
0
];
this
.
listEntries
=
[{
id
:
'
keybinding-header-entry
'
,
templateId
:
KEYBINDING_HEADER_TEMPLATE_ID
},
...
keybindingsEntries
];
this
.
listEntries
=
[{
id
:
'
keybinding-header-entry
'
,
templateId
:
KEYBINDING_HEADER_TEMPLATE_ID
},
...
keybindingsEntries
];
this
.
keybindingsList
.
splice
(
0
,
this
.
keybindingsList
.
length
,
this
.
listEntries
);
this
.
keybindingsList
.
splice
(
0
,
this
.
keybindingsList
.
length
,
this
.
listEntries
);
this
.
layoutKebindingsList
();
this
.
layoutKebindingsList
();
...
@@ -307,11 +311,11 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
...
@@ -307,11 +311,11 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
const
index
=
this
.
getNewIndexOfUnassignedKeybinding
(
this
.
unAssignedKeybindingItemToRevealAndFocus
);
const
index
=
this
.
getNewIndexOfUnassignedKeybinding
(
this
.
unAssignedKeybindingItemToRevealAndFocus
);
if
(
index
!==
-
1
)
{
if
(
index
!==
-
1
)
{
this
.
keybindingsList
.
reveal
(
index
,
0.2
);
this
.
keybindingsList
.
reveal
(
index
,
0.2
);
this
.
keybindingsList
.
setFocus
([
index
]
);
this
.
selectEntry
(
index
);
}
}
this
.
unAssignedKeybindingItemToRevealAndFocus
=
null
;
this
.
unAssignedKeybindingItemToRevealAndFocus
=
null
;
}
else
if
(
current
FocussedIndex
!==
-
1
&&
currentFocuss
edIndex
<
this
.
listEntries
.
length
)
{
}
else
if
(
current
SelectedIndex
!==
-
1
&&
currentSelect
edIndex
<
this
.
listEntries
.
length
)
{
this
.
keybindingsList
.
setFocus
([
currentFocussedIndex
]
);
this
.
selectEntry
(
currentSelectedIndex
);
}
}
}
}
...
@@ -346,23 +350,26 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
...
@@ -346,23 +350,26 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
return
-
1
;
return
-
1
;
}
}
private
focusEntry
(
keybindingItemEntry
:
IKeybindingItemEntry
):
void
{
private
selectEntry
(
keybindingItemEntry
:
IKeybindingItemEntry
|
number
):
void
{
const
index
=
this
.
getIndexOf
(
keybindingItemEntry
);
const
index
=
t
ypeof
keybindingItemEntry
===
'
number
'
?
keybindingItemEntry
:
t
his
.
getIndexOf
(
keybindingItemEntry
);
if
(
index
!==
-
1
)
{
if
(
index
!==
-
1
)
{
this
.
keybindingsList
.
getHTMLElement
().
focus
();
this
.
keybindingsList
.
getHTMLElement
().
focus
();
this
.
keybindingsList
.
setFocus
([
index
]);
this
.
keybindingsList
.
setFocus
([
index
]);
this
.
keybindingsList
.
setSelection
([
index
]);
}
}
}
}
private
_onNavigate
(
back
:
boolean
):
void
{
private
_onNavigate
(
back
:
boolean
):
void
{
if
(
!
back
)
{
if
(
!
back
)
{
this
.
keybindingsList
.
getHTMLElement
().
focus
();
this
.
keybindingsList
.
getHTMLElement
().
focus
();
this
.
keybindingsList
.
setFocus
([
0
]);
const
currentFocusIndices
=
this
.
keybindingsList
.
getFocus
();
this
.
keybindingsList
.
setFocus
([
currentFocusIndices
.
length
?
currentFocusIndices
[
0
]
:
0
]);
}
}
}
}
private
onContextMenu
(
e
:
IListContextMenuEvent
<
IListEntry
>
):
void
{
private
onContextMenu
(
e
:
IListContextMenuEvent
<
IListEntry
>
):
void
{
if
(
e
.
element
.
templateId
===
KEYBINDING_ENTRY_TEMPLATE_ID
)
{
if
(
e
.
element
.
templateId
===
KEYBINDING_ENTRY_TEMPLATE_ID
)
{
this
.
selectEntry
(
<
IKeybindingItemEntry
>
e
.
element
);
this
.
contextMenuService
.
showContextMenu
({
this
.
contextMenuService
.
showContextMenu
({
getAnchor
:
()
=>
e
.
anchor
,
getAnchor
:
()
=>
e
.
anchor
,
getActions
:
()
=>
TPromise
.
as
([
this
.
createCopyAction
(
<
IKeybindingItemEntry
>
e
.
element
),
new
Separator
(),
this
.
createRemoveAction
(
<
IKeybindingItemEntry
>
e
.
element
),
this
.
createResetAction
(
<
IKeybindingItemEntry
>
e
.
element
)]),
getActions
:
()
=>
TPromise
.
as
([
this
.
createCopyAction
(
<
IKeybindingItemEntry
>
e
.
element
),
new
Separator
(),
this
.
createRemoveAction
(
<
IKeybindingItemEntry
>
e
.
element
),
this
.
createResetAction
(
<
IKeybindingItemEntry
>
e
.
element
)]),
...
@@ -386,12 +393,6 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
...
@@ -386,12 +393,6 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
}
}
}
}
private
onKeybindingsListDOMFocus
():
void
{
if
(
!
this
.
keybindingsList
.
getFocusedElements
().
length
)
{
this
.
keybindingsList
.
focusNext
();
}
}
private
createRemoveAction
(
keybindingItem
:
IKeybindingItemEntry
):
IAction
{
private
createRemoveAction
(
keybindingItem
:
IKeybindingItemEntry
):
IAction
{
return
<
IAction
>
{
return
<
IAction
>
{
label
:
localize
(
'
removeLabel
'
,
"
Remove Keybinding
"
),
label
:
localize
(
'
removeLabel
'
,
"
Remove Keybinding
"
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录