Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f51ed6a6
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,发现更多精彩内容 >>
提交
f51ed6a6
编写于
3月 20, 2017
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#18095 Show kyebinding label if has highlights
上级
2a2f3dee
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
53 addition
and
21 deletion
+53
-21
src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts
.../workbench/parts/preferences/browser/keybindingsEditor.ts
+3
-0
src/vs/workbench/parts/preferences/common/keybindingsEditorModel.ts
...kbench/parts/preferences/common/keybindingsEditorModel.ts
+50
-21
未找到文件。
src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts
浏览文件 @
f51ed6a6
...
...
@@ -513,6 +513,9 @@ class KeybindingColumn extends Column {
let
htmlkb
=
keybindingItemEntry
.
keybindingItem
.
keybinding
.
getHTMLLabel
();
htmlkb
.
forEach
(
item
=>
keybinding
.
appendChild
(
renderHtml
(
item
)));
keybinding
.
title
=
keybindingItemEntry
.
keybindingItem
.
keybinding
.
getAriaLabel
();
if
(
keybindingItemEntry
.
keybindingMatches
)
{
new
HighlightedLabel
(
DOM
.
append
(
this
.
keybindingColumn
,
$
(
''
))).
set
(
keybindingItemEntry
.
keybindingItem
.
keybindingItem
.
resolvedKeybinding
.
getAriaLabel
(),
keybindingItemEntry
.
keybindingMatches
);
}
}
}
}
...
...
src/vs/workbench/parts/preferences/common/keybindingsEditorModel.ts
浏览文件 @
f51ed6a6
...
...
@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
distinct
}
from
'
vs/base/common/arrays
'
;
import
{
IMatch
,
IFilter
,
or
,
matchesContiguousSubString
,
matchesPrefix
,
matchesCamelCase
,
matchesWords
}
from
'
vs/base/common/filters
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
ResolvedKeybinding
}
from
'
vs/base/common/keyCodes
'
;
...
...
@@ -62,17 +63,15 @@ export class KeybindingsEditorModel extends EditorModel {
private
fetchKeybindingItems
(
searchValue
:
string
):
IKeybindingItemEntry
[]
{
const
result
:
IKeybindingItemEntry
[]
=
[];
for
(
const
keybindingItem
of
this
.
_keybindingItems
)
{
let
keybindingMatches
:
IMatch
[]
=
keybindingItem
.
keybinding
?
KeybindingsEditorModel
.
matches
(
searchValue
,
keybindingItem
.
keybinding
.
getAriaLabel
(),
or
(
matchesWords
,
matchesCamelCase
))
:
null
;
let
commandIdMatches
:
IMatch
[]
=
KeybindingsEditorModel
.
matches
(
searchValue
,
keybindingItem
.
command
,
or
(
matchesWords
,
matchesCamelCase
));
let
commandLabelMatches
:
IMatch
[]
=
keybindingItem
.
commandLabel
?
KeybindingsEditorModel
.
matches
(
searchValue
,
keybindingItem
.
commandLabel
,
(
word
,
wordToMatchAgainst
)
=>
matchesWords
(
word
,
keybindingItem
.
commandLabel
,
true
))
:
null
;
if
(
keybindingMatches
||
commandIdMatches
||
commandLabelMatches
)
{
let
keybindingMatches
=
new
KeybindingMatches
(
keybindingItem
,
searchValue
);
if
(
keybindingMatches
.
commandIdMatches
||
keybindingMatches
.
commandLabelMatches
||
keybindingMatches
.
keybindingMatches
)
{
result
.
push
({
id
:
KeybindingsEditorModel
.
getId
(
keybindingItem
),
templateId
:
KEYBINDING_ENTRY_TEMPLATE_ID
,
commandLabelMatches
,
commandLabelMatches
:
keybindingMatches
.
commandLabelMatches
,
keybindingItem
,
keybindingMatches
,
commandIdMatches
keybindingMatches
:
keybindingMatches
.
keybindingMatches
,
commandIdMatches
:
keybindingMatches
.
commandIdMatches
});
}
}
...
...
@@ -153,26 +152,56 @@ export class KeybindingsEditorModel extends EditorModel {
source
:
KeybindingSource
.
Default
};
}
}
class
KeybindingMatches
{
public
readonly
commandIdMatches
:
IMatch
[]
=
null
;
public
readonly
commandLabelMatches
:
IMatch
[]
=
null
;
public
readonly
keybindingMatches
:
IMatch
[]
=
null
;
private
static
matches
(
searchValue
:
string
,
wordToMatchAgainst
:
string
,
wordMatchesFilter
:
IFilter
):
IMatch
[]
{
constructor
(
keybindingItem
:
IKeybindingItem
,
searchValue
:
string
)
{
this
.
commandIdMatches
=
this
.
matches
(
searchValue
,
keybindingItem
.
command
,
or
(
matchesWords
,
matchesCamelCase
));
this
.
commandLabelMatches
=
keybindingItem
.
commandLabel
?
this
.
matches
(
searchValue
,
keybindingItem
.
commandLabel
,
(
word
,
wordToMatchAgainst
)
=>
matchesWords
(
word
,
keybindingItem
.
commandLabel
,
true
))
:
null
;
this
.
keybindingMatches
=
keybindingItem
.
keybinding
?
this
.
keyMatches
(
searchValue
,
keybindingItem
.
keybinding
.
getAriaLabel
(),
or
(
matchesWords
,
matchesCamelCase
))
:
null
;
}
private
matches
(
searchValue
:
string
,
wordToMatchAgainst
:
string
,
wordMatchesFilter
:
IFilter
):
IMatch
[]
{
let
matches
=
wordFilter
(
searchValue
,
wordToMatchAgainst
);
if
(
!
matches
)
{
const
words
=
searchValue
.
split
(
'
'
);
for
(
const
word
of
words
)
{
const
wordMatches
=
wordMatchesFilter
(
word
,
wordToMatchAgainst
);
if
(
wordMatches
)
{
matches
=
[...(
matches
||
[]),
...
wordMatches
];
}
else
{
matches
=
null
;
break
;
}
}
matches
=
this
.
matchesWords
(
searchValue
.
split
(
'
'
),
wordToMatchAgainst
,
wordMatchesFilter
);
}
if
(
matches
)
{
matches
.
sort
((
a
,
b
)
=>
{
return
a
.
start
-
b
.
start
;
});
matches
=
this
.
filterAndSort
(
matches
);
}
return
matches
;
}
private
keyMatches
(
searchValue
:
string
,
wordToMatchAgainst
:
string
,
wordMatchesFilter
:
IFilter
):
IMatch
[]
{
let
matches
=
this
.
matches
(
searchValue
,
wordToMatchAgainst
,
wordMatchesFilter
);
if
(
!
matches
)
{
matches
=
this
.
matchesWords
(
searchValue
.
split
(
'
+
'
),
wordToMatchAgainst
,
wordMatchesFilter
);
if
(
matches
)
{
matches
=
this
.
filterAndSort
(
matches
);
}
}
return
matches
;
}
private
matchesWords
(
words
:
string
[],
wordToMatchAgainst
:
string
,
wordMatchesFilter
:
IFilter
):
IMatch
[]
{
let
matches
=
[];
for
(
const
word
of
words
)
{
const
wordMatches
=
wordMatchesFilter
(
word
,
wordToMatchAgainst
);
if
(
wordMatches
)
{
matches
=
[...(
matches
||
[]),
...
wordMatches
];
}
else
{
matches
=
null
;
break
;
}
}
return
matches
;
}
private
filterAndSort
(
matches
:
IMatch
[]):
IMatch
[]
{
return
distinct
(
matches
,
(
a
=>
a
.
start
+
'
.
'
+
a
.
end
)).
filter
(
match
=>
!
matches
.
some
(
m
=>
!
(
m
.
start
===
match
.
start
&&
m
.
end
===
match
.
end
)
&&
(
m
.
start
<=
match
.
start
&&
m
.
end
>=
match
.
end
))).
sort
((
a
,
b
)
=>
a
.
start
-
b
.
start
);;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录