Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b64faa99
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,发现更多精彩内容 >>
提交
b64faa99
编写于
3月 14, 2018
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish #43037
上级
a716373a
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
32 addition
and
41 deletion
+32
-41
src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts
.../workbench/parts/preferences/browser/keybindingsEditor.ts
+2
-2
src/vs/workbench/parts/preferences/common/keybindingsEditorModel.ts
...kbench/parts/preferences/common/keybindingsEditorModel.ts
+30
-39
未找到文件。
src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts
浏览文件 @
b64faa99
...
...
@@ -184,7 +184,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
enabled
:
true
,
id
:
KEYBINDINGS_EDITOR_SHOW_DEFAULT_KEYBINDINGS
,
run
:
():
TPromise
<
any
>
=>
{
this
.
searchWidget
.
setValue
(
'
@source:
default
'
);
this
.
searchWidget
.
setValue
(
'
@source:default
'
);
return
TPromise
.
as
(
null
);
}
},
...
...
@@ -193,7 +193,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
enabled
:
true
,
id
:
KEYBINDINGS_EDITOR_SHOW_USER_KEYBINDINGS
,
run
:
():
TPromise
<
any
>
=>
{
this
.
searchWidget
.
setValue
(
'
@source:
user
'
);
this
.
searchWidget
.
setValue
(
'
@source:user
'
);
return
TPromise
.
as
(
null
);
}
}
...
...
src/vs/workbench/parts/preferences/common/keybindingsEditorModel.ts
浏览文件 @
b64faa99
...
...
@@ -23,6 +23,9 @@ import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingReso
export
const
KEYBINDING_ENTRY_TEMPLATE_ID
=
'
keybinding.entry.template
'
;
export
const
KEYBINDING_HEADER_TEMPLATE_ID
=
'
keybinding.header.template
'
;
const
SOURCE_DEFAULT
=
localize
(
'
default
'
,
"
Default
"
);
const
SOURCE_USER
=
localize
(
'
user
'
,
"
User
"
);
export
interface
KeybindingMatch
{
ctrlKey
?:
boolean
;
shiftKey
?:
boolean
;
...
...
@@ -89,55 +92,43 @@ export class KeybindingsEditorModel extends EditorModel {
}
public
fetch
(
searchValue
:
string
,
sortByPrecedence
:
boolean
=
false
):
IKeybindingItemEntry
[]
{
searchValue
=
searchValue
.
trim
();
const
quoteAtFirstChar
=
searchValue
.
charAt
(
0
)
===
'
"
'
;
const
quoteAtLastChar
=
searchValue
.
charAt
(
searchValue
.
length
-
1
)
===
'
"
'
;
if
(
quoteAtFirstChar
)
{
searchValue
=
searchValue
.
substring
(
1
);
}
if
(
quoteAtLastChar
)
{
searchValue
=
searchValue
.
substring
(
0
,
searchValue
.
length
-
1
);
}
searchValue
=
searchValue
.
trim
();
return
this
.
fetchKeybindingItems
(
sortByPrecedence
?
this
.
_keybindingItemsSortedByPrecedence
:
this
.
_keybindingItems
,
searchValue
,
quoteAtFirstChar
&&
quoteAtLastChar
);
let
keybindingItems
=
sortByPrecedence
?
this
.
_keybindingItemsSortedByPrecedence
:
this
.
_keybindingItems
;
if
(
/@source:
\s
*
(
user|default
)
/i
.
test
(
searchValue
))
{
keybindingItems
=
this
.
filterBySource
(
keybindingItems
,
searchValue
);
searchValue
=
searchValue
.
replace
(
/@source:
\s
*
(
user|default
)
/i
,
''
);
}
private
fetchKeybindingItems
(
keybindingItems
:
IKeybindingItem
[],
searchValue
:
string
,
completeMatch
:
boolean
):
IKeybindingItemEntry
[]
{
searchValue
=
searchValue
.
trim
();
if
(
!
searchValue
)
{
return
keybindingItems
.
map
(
keybindingItem
=>
({
id
:
KeybindingsEditorModel
.
getId
(
keybindingItem
),
keybindingItem
,
templateId
:
KEYBINDING_ENTRY_TEMPLATE_ID
}));
}
if
(
this
.
isSourceFilterApplied
(
searchValue
))
{
return
this
.
filterBySource
(
keybindingItems
,
this
.
getSourceFilterValue
(
searchValue
),
completeMatch
);
}
return
this
.
filterByText
(
keybindingItems
,
searchValue
,
completeMatch
);
return
this
.
filterByText
(
keybindingItems
,
searchValue
);
}
private
isSourceFilterApplied
(
searchValue
:
string
):
boolean
{
return
/^@source:/i
.
test
(
searchValue
);
private
filterBySource
(
keybindingItems
:
IKeybindingItem
[],
searchValue
:
string
):
IKeybindingItem
[]
{
if
(
/@source:
\s
*default/i
.
test
(
searchValue
))
{
return
keybindingItems
.
filter
(
k
=>
k
.
source
===
SOURCE_DEFAULT
);
}
private
getSourceFilterValue
(
searchValue
:
string
):
string
{
return
searchValue
.
split
(
'
@source:
'
)[
1
].
trim
()
||
''
;
if
(
/@source:
\s
*user/i
.
test
(
searchValue
))
{
return
keybindingItems
.
filter
(
k
=>
k
.
source
===
SOURCE_USER
);
}
private
matchSource
(
itemSource
:
string
,
searchValue
:
string
):
boolean
{
return
itemSource
.
toLowerCase
()
===
searchValue
.
toLowerCase
();
return
keybindingItems
;
}
private
filterBySource
(
keybindingItems
:
IKeybindingItem
[],
searchValue
:
string
,
completeMatch
:
boolean
):
IKeybindingItemEntry
[]
{
return
<
IKeybindingItemEntry
[]
>
keybindingItems
.
filter
((
keybindingItem
:
IKeybindingItem
)
=>
this
.
matchSource
(
keybindingItem
.
source
,
searchValue
))
.
map
((
keybindingItem
:
IKeybindingItem
)
=>
(
{
id
:
KeybindingsEditorModel
.
getId
(
keybindingItem
),
templateId
:
KEYBINDING_ENTRY_TEMPLATE_ID
,
keybindingItem
,
private
filterByText
(
keybindingItems
:
IKeybindingItem
[],
searchValue
:
string
):
IKeybindingItemEntry
[]
{
const
quoteAtFirstChar
=
searchValue
.
charAt
(
0
)
===
'
"
'
;
const
quoteAtLastChar
=
searchValue
.
charAt
(
searchValue
.
length
-
1
)
===
'
"
'
;
const
completeMatch
=
quoteAtFirstChar
&&
quoteAtLastChar
;
if
(
quoteAtFirstChar
)
{
searchValue
=
searchValue
.
substring
(
1
);
}
));
if
(
quoteAtLastChar
)
{
searchValue
=
searchValue
.
substring
(
0
,
searchValue
.
length
-
1
);
}
searchValue
=
searchValue
.
trim
();
private
filterByText
(
keybindingItems
:
IKeybindingItem
[],
searchValue
:
string
,
completeMatch
:
boolean
):
IKeybindingItemEntry
[]
{
const
result
:
IKeybindingItemEntry
[]
=
[];
const
words
=
searchValue
.
split
(
'
'
);
const
keybindingWords
=
this
.
splitKeybindingWords
(
words
);
...
...
@@ -235,7 +226,7 @@ export class KeybindingsEditorModel extends EditorModel {
commandLabel
:
KeybindingsEditorModel
.
getCommandLabel
(
menuCommand
,
editorActionLabel
),
commandDefaultLabel
:
KeybindingsEditorModel
.
getCommandDefaultLabel
(
menuCommand
,
workbenchActionsRegistry
),
when
:
keybindingItem
.
when
?
keybindingItem
.
when
.
serialize
()
:
''
,
source
:
keybindingItem
.
isDefault
?
localize
(
'
default
'
,
"
Default
"
)
:
localize
(
'
user
'
,
"
User
"
)
source
:
keybindingItem
.
isDefault
?
SOURCE_DEFAULT
:
SOURCE_USER
};
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录