Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
27a53ad3
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,发现更多精彩内容 >>
提交
27a53ad3
编写于
3月 27, 2017
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#18095 Include when and source label in Search
上级
0c126b4f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
19 deletion
+34
-19
src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts
.../workbench/parts/preferences/browser/keybindingsEditor.ts
+8
-7
src/vs/workbench/parts/preferences/common/keybindingsEditorModel.ts
...kbench/parts/preferences/common/keybindingsEditorModel.ts
+26
-12
未找到文件。
src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts
浏览文件 @
27a53ad3
...
...
@@ -18,7 +18,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import
{
IClipboardService
}
from
'
vs/platform/clipboard/common/clipboardService
'
;
import
{
KeybindingsEditorModel
,
IKeybindingItemEntry
,
IListEntry
,
KEYBINDING_ENTRY_TEMPLATE_ID
,
KEYBINDING_HEADER_TEMPLATE_ID
}
from
'
vs/workbench/parts/preferences/common/keybindingsEditorModel
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IKeybindingService
,
KeybindingSource
,
IUserFriendlyKeybinding
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IKeybindingService
,
IUserFriendlyKeybinding
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
SearchWidget
}
from
'
vs/workbench/parts/preferences/browser/preferencesWidgets
'
;
import
{
DefineKeybindingWidget
}
from
'
vs/workbench/parts/preferences/browser/keybindingWidgets
'
;
import
{
IPreferencesService
,
IKeybindingsEditor
,
CONTEXT_KEYBINDING_FOCUS
,
CONTEXT_KEYBINDINGS_EDITOR
,
KEYBINDINGS_EDITOR_COMMAND_REMOVE
,
KEYBINDINGS_EDITOR_COMMAND_COPY
,
KEYBINDINGS_EDITOR_COMMAND_RESET
,
KEYBINDINGS_EDITOR_COMMAND_DEFINE
}
from
'
vs/workbench/parts/preferences/common/preferences
'
;
...
...
@@ -225,7 +225,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
key
:
keybinding
.
keybindingItem
.
keybinding
?
keybinding
.
keybindingItem
.
keybinding
.
getUserSettingsLabel
()
:
''
};
if
(
keybinding
.
keybindingItem
.
when
)
{
userFriendlyKeybinding
.
when
=
keybinding
.
keybindingItem
.
when
.
serialize
()
;
userFriendlyKeybinding
.
when
=
keybinding
.
keybindingItem
.
when
;
}
this
.
clipboardService
.
writeText
(
JSON
.
stringify
(
userFriendlyKeybinding
,
null
,
'
'
));
return
TPromise
.
as
(
null
);
...
...
@@ -400,7 +400,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
private
createResetAction
(
keybindingItem
:
IKeybindingItemEntry
):
IAction
{
return
<
IAction
>
{
label
:
localize
(
'
resetLabel
'
,
"
Reset Keybinding
"
),
enabled
:
!!
keybindingItem
.
keybindingItem
.
keybinding
&&
keybindingItem
.
keybindingItem
.
source
===
KeybindingSource
.
User
,
enabled
:
!!
keybindingItem
.
keybindingItem
.
keybinding
&&
!
keybindingItem
.
keybindingItem
.
keybindingItem
.
isDefault
,
id
:
KEYBINDINGS_EDITOR_COMMAND_RESET
,
run
:
()
=>
this
.
resetKeybinding
(
keybindingItem
)
};
...
...
@@ -621,7 +621,8 @@ class SourceColumn extends Column {
}
render
(
keybindingItemEntry
:
IKeybindingItemEntry
):
void
{
this
.
sourceColumn
.
textContent
=
keybindingItemEntry
.
keybindingItem
.
source
===
KeybindingSource
.
User
?
localize
(
'
user
'
,
"
User
"
)
:
localize
(
'
default
'
,
"
Default
"
);
DOM
.
clearNode
(
this
.
sourceColumn
);
new
HighlightedLabel
(
this
.
sourceColumn
).
set
(
keybindingItemEntry
.
keybindingItem
.
source
,
keybindingItemEntry
.
sourceMatches
);
}
}
...
...
@@ -635,12 +636,12 @@ class WhenColumn extends Column {
}
render
(
keybindingItemEntry
:
IKeybindingItemEntry
):
void
{
DOM
.
clearNode
(
this
.
whenColumn
);
DOM
.
toggleClass
(
this
.
whenColumn
,
'
code
'
,
!!
keybindingItemEntry
.
keybindingItem
.
when
);
DOM
.
toggleClass
(
this
.
whenColumn
,
'
empty
'
,
!
keybindingItemEntry
.
keybindingItem
.
when
);
if
(
keybindingItemEntry
.
keybindingItem
.
when
)
{
const
when
=
keybindingItemEntry
.
keybindingItem
.
when
.
serialize
();
this
.
whenColumn
.
textContent
=
when
;
this
.
whenColumn
.
title
=
when
;
new
HighlightedLabel
(
this
.
whenColumn
).
set
(
keybindingItemEntry
.
keybindingItem
.
when
,
keybindingItemEntry
.
whenMatches
);
this
.
whenColumn
.
title
=
keybindingItemEntry
.
keybindingItem
.
when
;
}
else
{
this
.
whenColumn
.
textContent
=
'
—
'
;
}
...
...
src/vs/workbench/parts/preferences/common/keybindingsEditorModel.ts
浏览文件 @
27a53ad3
...
...
@@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
localize
}
from
'
vs/nls
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
distinct
}
from
'
vs/base/common/arrays
'
;
import
{
language
,
LANGUAGE_DEFAULT
}
from
'
vs/base/common/platform
'
;
...
...
@@ -13,10 +14,9 @@ import { CommonEditorRegistry, EditorAction } from 'vs/editor/common/editorCommo
import
{
IWorkbenchActionRegistry
,
Extensions
as
ActionExtensions
}
from
'
vs/workbench/common/actionRegistry
'
;
import
{
EditorModel
}
from
'
vs/workbench/common/editor
'
;
import
{
IExtensionService
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
IKeybindingService
,
KeybindingSource
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
ResolvedKeybindingItem
}
from
'
vs/platform/keybinding/common/resolvedKeybindingItem
'
;
import
{
KeybindingResolver
}
from
'
vs/platform/keybinding/common/keybindingResolver
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
export
const
KEYBINDING_ENTRY_TEMPLATE_ID
=
'
keybinding.entry.template
'
;
export
const
KEYBINDING_HEADER_TEMPLATE_ID
=
'
keybinding.header.template
'
;
...
...
@@ -31,6 +31,8 @@ export interface IKeybindingItemEntry extends IListEntry {
commandIdMatches
?:
IMatch
[];
commandLabelMatches
?:
IMatch
[];
commandDefaultLabelMatches
?:
IMatch
[];
sourceMatches
?:
IMatch
[];
whenMatches
?:
IMatch
[];
keybindingMatches
?:
IMatch
[];
}
...
...
@@ -40,8 +42,8 @@ export interface IKeybindingItem {
commandLabel
:
string
;
commandDefaultLabel
:
string
;
command
:
string
;
source
:
KeybindingSource
;
when
:
ContextKeyExpr
;
source
:
string
;
when
:
string
;
}
const
wordFilter
=
or
(
matchesPrefix
,
matchesWords
,
matchesContiguousSubString
);
...
...
@@ -67,7 +69,12 @@ export class KeybindingsEditorModel extends EditorModel {
const
result
:
IKeybindingItemEntry
[]
=
[];
for
(
const
keybindingItem
of
this
.
_keybindingItems
)
{
let
keybindingMatches
=
new
KeybindingMatches
(
keybindingItem
,
searchValue
);
if
(
keybindingMatches
.
commandIdMatches
||
keybindingMatches
.
commandLabelMatches
||
keybindingMatches
.
commandDefaultLabelMatches
||
keybindingMatches
.
keybindingMatches
)
{
if
(
keybindingMatches
.
commandIdMatches
||
keybindingMatches
.
commandLabelMatches
||
keybindingMatches
.
commandDefaultLabelMatches
||
keybindingMatches
.
sourceMatches
||
keybindingMatches
.
whenMatches
||
keybindingMatches
.
keybindingMatches
)
{
result
.
push
({
id
:
KeybindingsEditorModel
.
getId
(
keybindingItem
),
templateId
:
KEYBINDING_ENTRY_TEMPLATE_ID
,
...
...
@@ -75,7 +82,9 @@ export class KeybindingsEditorModel extends EditorModel {
commandDefaultLabelMatches
:
keybindingMatches
.
commandDefaultLabelMatches
,
keybindingItem
,
keybindingMatches
:
keybindingMatches
.
keybindingMatches
,
commandIdMatches
:
keybindingMatches
.
commandIdMatches
commandIdMatches
:
keybindingMatches
.
commandIdMatches
,
sourceMatches
:
keybindingMatches
.
sourceMatches
,
whenMatches
:
keybindingMatches
.
whenMatches
});
}
}
...
...
@@ -109,7 +118,7 @@ export class KeybindingsEditorModel extends EditorModel {
}
private
static
getId
(
keybindingItem
:
IKeybindingItem
):
string
{
return
keybindingItem
.
command
+
(
keybindingItem
.
keybinding
?
keybindingItem
.
keybinding
.
getAriaLabel
()
:
''
)
+
keybindingItem
.
source
+
(
keybindingItem
.
when
?
keybindingItem
.
when
.
serialize
()
:
''
)
;
return
keybindingItem
.
command
+
(
keybindingItem
.
keybinding
?
keybindingItem
.
keybinding
.
getAriaLabel
()
:
''
)
+
keybindingItem
.
source
+
keybindingItem
.
when
;
}
private
static
compareKeybindingData
(
a
:
IKeybindingItem
,
b
:
IKeybindingItem
):
number
{
...
...
@@ -131,7 +140,7 @@ export class KeybindingsEditorModel extends EditorModel {
}
}
if
(
a
.
command
===
b
.
command
)
{
return
a
.
source
===
KeybindingSource
.
User
?
-
1
:
1
;
return
a
.
keybindingItem
.
isDefault
?
1
:
-
1
;
}
return
a
.
command
.
localeCompare
(
b
.
command
);
}
...
...
@@ -140,14 +149,15 @@ export class KeybindingsEditorModel extends EditorModel {
const
workbenchAction
=
workbenchActionsRegistry
.
getWorkbenchAction
(
command
);
const
editorAction
:
EditorAction
=
editorActions
[
command
];
const
commandDefaultLabel
=
workbenchAction
&&
language
!==
LANGUAGE_DEFAULT
?
workbenchActionsRegistry
.
getAlias
(
workbenchAction
.
id
)
:
null
;
keybindingItem
=
keybindingItem
?
keybindingItem
:
new
ResolvedKeybindingItem
(
null
,
command
,
null
,
null
,
true
);
return
<
IKeybindingItem
>
{
keybinding
:
keybindingItem
?
keybindingItem
.
resolvedKeybinding
:
null
,
keybindingItem
:
keybindingItem
?
keybindingItem
:
new
ResolvedKeybindingItem
(
null
,
command
,
null
,
null
,
true
)
,
keybinding
:
keybindingItem
.
resolvedKeybinding
,
keybindingItem
,
command
,
commandLabel
:
editorAction
?
editorAction
.
label
:
workbenchAction
?
workbenchAction
.
label
:
''
,
commandDefaultLabel
,
when
:
keybindingItem
?
keybindingItem
.
when
:
null
,
source
:
!
keybindingItem
||
keybindingItem
.
isDefault
?
KeybindingSource
.
Default
:
KeybindingSource
.
User
when
:
keybindingItem
.
when
?
keybindingItem
.
when
.
serialize
()
:
''
,
source
:
keybindingItem
.
isDefault
?
localize
(
'
default
'
,
"
Default
"
)
:
localize
(
'
user
'
,
"
User
"
)
};
}
}
...
...
@@ -156,12 +166,16 @@ class KeybindingMatches {
public
readonly
commandIdMatches
:
IMatch
[]
=
null
;
public
readonly
commandLabelMatches
:
IMatch
[]
=
null
;
public
readonly
commandDefaultLabelMatches
:
IMatch
[]
=
null
;
public
readonly
sourceMatches
:
IMatch
[]
=
null
;
public
readonly
whenMatches
:
IMatch
[]
=
null
;
public
readonly
keybindingMatches
:
IMatch
[]
=
null
;
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
.
commandDefaultLabelMatches
=
keybindingItem
.
commandDefaultLabel
?
this
.
matches
(
searchValue
,
keybindingItem
.
commandDefaultLabel
,
(
word
,
wordToMatchAgainst
)
=>
matchesWords
(
word
,
keybindingItem
.
commandDefaultLabel
,
true
))
:
null
;
this
.
sourceMatches
=
this
.
matches
(
searchValue
,
keybindingItem
.
source
,
(
word
,
wordToMatchAgainst
)
=>
matchesWords
(
word
,
keybindingItem
.
source
,
true
));
this
.
whenMatches
=
keybindingItem
.
when
?
this
.
matches
(
searchValue
,
keybindingItem
.
when
,
or
(
matchesWords
,
matchesCamelCase
))
:
null
;
this
.
keybindingMatches
=
keybindingItem
.
keybinding
?
this
.
keyMatches
(
searchValue
,
keybindingItem
.
keybinding
.
getAriaLabel
(),
or
(
matchesWords
,
matchesCamelCase
))
:
null
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录