Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7e407b54
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,发现更多精彩内容 >>
提交
7e407b54
编写于
5月 25, 2020
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #98489
上级
112417a0
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
99 addition
and
59 deletion
+99
-59
src/vs/workbench/services/preferences/common/keybindingsEditorModel.ts
...nch/services/preferences/common/keybindingsEditorModel.ts
+58
-58
src/vs/workbench/services/preferences/test/common/keybindingsEditorModel.test.ts
...es/preferences/test/common/keybindingsEditorModel.test.ts
+41
-1
未找到文件。
src/vs/workbench/services/preferences/common/keybindingsEditorModel.ts
浏览文件 @
7e407b54
...
...
@@ -421,22 +421,6 @@ class KeybindingItemMatches {
return
this
.
wordMatchesMetaModifier
(
word
);
}
private
wordMatchesMetaModifier
(
word
:
string
):
boolean
{
if
(
matchesPrefix
(
this
.
modifierLabels
.
ui
.
metaKey
,
word
))
{
return
true
;
}
if
(
matchesPrefix
(
this
.
modifierLabels
.
aria
.
metaKey
,
word
))
{
return
true
;
}
if
(
matchesPrefix
(
this
.
modifierLabels
.
user
.
metaKey
,
word
))
{
return
true
;
}
if
(
matchesPrefix
(
localize
(
'
meta
'
,
"
meta
"
),
word
))
{
return
true
;
}
return
false
;
}
private
matchesCtrlModifier
(
keybinding
:
ResolvedKeybindingPart
|
null
,
word
:
string
):
boolean
{
if
(
!
keybinding
)
{
return
false
;
...
...
@@ -447,19 +431,6 @@ class KeybindingItemMatches {
return
this
.
wordMatchesCtrlModifier
(
word
);
}
private
wordMatchesCtrlModifier
(
word
:
string
):
boolean
{
if
(
matchesPrefix
(
this
.
modifierLabels
.
ui
.
ctrlKey
,
word
))
{
return
true
;
}
if
(
matchesPrefix
(
this
.
modifierLabels
.
aria
.
ctrlKey
,
word
))
{
return
true
;
}
if
(
matchesPrefix
(
this
.
modifierLabels
.
user
.
ctrlKey
,
word
))
{
return
true
;
}
return
false
;
}
private
matchesShiftModifier
(
keybinding
:
ResolvedKeybindingPart
|
null
,
word
:
string
):
boolean
{
if
(
!
keybinding
)
{
return
false
;
...
...
@@ -470,19 +441,6 @@ class KeybindingItemMatches {
return
this
.
wordMatchesShiftModifier
(
word
);
}
private
wordMatchesShiftModifier
(
word
:
string
):
boolean
{
if
(
matchesPrefix
(
this
.
modifierLabels
.
ui
.
shiftKey
,
word
))
{
return
true
;
}
if
(
matchesPrefix
(
this
.
modifierLabels
.
aria
.
shiftKey
,
word
))
{
return
true
;
}
if
(
matchesPrefix
(
this
.
modifierLabels
.
user
.
shiftKey
,
word
))
{
return
true
;
}
return
false
;
}
private
matchesAltModifier
(
keybinding
:
ResolvedKeybindingPart
|
null
,
word
:
string
):
boolean
{
if
(
!
keybinding
)
{
return
false
;
...
...
@@ -493,22 +451,6 @@ class KeybindingItemMatches {
return
this
.
wordMatchesAltModifier
(
word
);
}
private
wordMatchesAltModifier
(
word
:
string
):
boolean
{
if
(
matchesPrefix
(
this
.
modifierLabels
.
ui
.
altKey
,
word
))
{
return
true
;
}
if
(
matchesPrefix
(
this
.
modifierLabels
.
aria
.
altKey
,
word
))
{
return
true
;
}
if
(
matchesPrefix
(
this
.
modifierLabels
.
user
.
altKey
,
word
))
{
return
true
;
}
if
(
matchesPrefix
(
localize
(
'
option
'
,
"
option
"
),
word
))
{
return
true
;
}
return
false
;
}
private
hasAnyMatch
(
keybindingMatch
:
KeybindingMatch
):
boolean
{
return
!!
keybindingMatch
.
altKey
||
!!
keybindingMatch
.
ctrlKey
||
...
...
@@ -574,4 +516,62 @@ class KeybindingItemMatches {
}
return
false
;
}
private
wordMatchesAltModifier
(
word
:
string
):
boolean
{
if
(
strings
.
equalsIgnoreCase
(
this
.
modifierLabels
.
ui
.
altKey
,
word
))
{
return
true
;
}
if
(
strings
.
equalsIgnoreCase
(
this
.
modifierLabels
.
aria
.
altKey
,
word
))
{
return
true
;
}
if
(
strings
.
equalsIgnoreCase
(
this
.
modifierLabels
.
user
.
altKey
,
word
))
{
return
true
;
}
if
(
strings
.
equalsIgnoreCase
(
localize
(
'
option
'
,
"
option
"
),
word
))
{
return
true
;
}
return
false
;
}
private
wordMatchesCtrlModifier
(
word
:
string
):
boolean
{
if
(
strings
.
equalsIgnoreCase
(
this
.
modifierLabels
.
ui
.
ctrlKey
,
word
))
{
return
true
;
}
if
(
strings
.
equalsIgnoreCase
(
this
.
modifierLabels
.
aria
.
ctrlKey
,
word
))
{
return
true
;
}
if
(
strings
.
equalsIgnoreCase
(
this
.
modifierLabels
.
user
.
ctrlKey
,
word
))
{
return
true
;
}
return
false
;
}
private
wordMatchesMetaModifier
(
word
:
string
):
boolean
{
if
(
strings
.
equalsIgnoreCase
(
this
.
modifierLabels
.
ui
.
metaKey
,
word
))
{
return
true
;
}
if
(
strings
.
equalsIgnoreCase
(
this
.
modifierLabels
.
aria
.
metaKey
,
word
))
{
return
true
;
}
if
(
strings
.
equalsIgnoreCase
(
this
.
modifierLabels
.
user
.
metaKey
,
word
))
{
return
true
;
}
if
(
strings
.
equalsIgnoreCase
(
localize
(
'
meta
'
,
"
meta
"
),
word
))
{
return
true
;
}
return
false
;
}
private
wordMatchesShiftModifier
(
word
:
string
):
boolean
{
if
(
strings
.
equalsIgnoreCase
(
this
.
modifierLabels
.
ui
.
shiftKey
,
word
))
{
return
true
;
}
if
(
strings
.
equalsIgnoreCase
(
this
.
modifierLabels
.
aria
.
shiftKey
,
word
))
{
return
true
;
}
if
(
strings
.
equalsIgnoreCase
(
this
.
modifierLabels
.
user
.
shiftKey
,
word
))
{
return
true
;
}
return
false
;
}
}
src/vs/workbench/services/preferences/test/common/keybindingsEditorModel.test.ts
浏览文件 @
7e407b54
...
...
@@ -34,7 +34,7 @@ class AnAction extends Action {
}
}
suite
(
'
KeybindingsEditorModel
test
'
,
()
=>
{
suite
(
'
KeybindingsEditorModel
'
,
()
=>
{
let
instantiationService
:
TestInstantiationService
;
let
testObject
:
KeybindingsEditorModel
;
...
...
@@ -568,6 +568,46 @@ suite('KeybindingsEditorModel test', () => {
assert
.
deepEqual
(
actual
[
0
].
keybindingMatches
!
.
firstPart
,
{
keyCode
:
true
});
});
test
(
'
filter modifiers are not matched when not completely matched (prefix)
'
,
async
()
=>
{
testObject
=
instantiationService
.
createInstance
(
KeybindingsEditorModel
,
OperatingSystem
.
Macintosh
);
const
term
=
`alt.
${
uuid
.
generateUuid
()}
`
;
const
command
=
`command.
${
term
}
`
;
const
expected
=
aResolvedKeybindingItem
({
command
,
firstPart
:
{
keyCode
:
KeyCode
.
Escape
},
isDefault
:
false
});
prepareKeybindingService
(
expected
,
aResolvedKeybindingItem
({
command
:
'
some_command
'
,
firstPart
:
{
keyCode
:
KeyCode
.
Escape
,
modifiers
:
{
altKey
:
true
}
},
isDefault
:
false
}));
await
testObject
.
resolve
(
new
Map
<
string
,
string
>
());
const
actual
=
testObject
.
fetch
(
term
);
assert
.
equal
(
1
,
actual
.
length
);
assert
.
equal
(
command
,
actual
[
0
].
keybindingItem
.
command
);
assert
.
equal
(
1
,
actual
[
0
].
commandIdMatches
?.
length
);
});
test
(
'
filter modifiers are not matched when not completely matched (includes)
'
,
async
()
=>
{
testObject
=
instantiationService
.
createInstance
(
KeybindingsEditorModel
,
OperatingSystem
.
Macintosh
);
const
term
=
`abcaltdef.
${
uuid
.
generateUuid
()}
`
;
const
command
=
`command.
${
term
}
`
;
const
expected
=
aResolvedKeybindingItem
({
command
,
firstPart
:
{
keyCode
:
KeyCode
.
Escape
},
isDefault
:
false
});
prepareKeybindingService
(
expected
,
aResolvedKeybindingItem
({
command
:
'
some_command
'
,
firstPart
:
{
keyCode
:
KeyCode
.
Escape
,
modifiers
:
{
altKey
:
true
}
},
isDefault
:
false
}));
await
testObject
.
resolve
(
new
Map
<
string
,
string
>
());
const
actual
=
testObject
.
fetch
(
term
);
assert
.
equal
(
1
,
actual
.
length
);
assert
.
equal
(
command
,
actual
[
0
].
keybindingItem
.
command
);
assert
.
equal
(
1
,
actual
[
0
].
commandIdMatches
?.
length
);
});
test
(
'
filter modifiers are matched with complete term
'
,
async
()
=>
{
testObject
=
instantiationService
.
createInstance
(
KeybindingsEditorModel
,
OperatingSystem
.
Macintosh
);
const
command
=
`command.
${
uuid
.
generateUuid
()}
`
;
const
expected
=
aResolvedKeybindingItem
({
command
,
firstPart
:
{
keyCode
:
KeyCode
.
Escape
,
modifiers
:
{
altKey
:
true
}
},
isDefault
:
false
});
prepareKeybindingService
(
expected
,
aResolvedKeybindingItem
({
command
:
'
some_command
'
,
firstPart
:
{
keyCode
:
KeyCode
.
Escape
},
isDefault
:
false
}));
await
testObject
.
resolve
(
new
Map
<
string
,
string
>
());
const
actual
=
testObject
.
fetch
(
'
alt
'
).
filter
(
element
=>
element
.
keybindingItem
.
command
===
command
);
assert
.
equal
(
1
,
actual
.
length
);
assert
.
deepEqual
(
actual
[
0
].
keybindingMatches
!
.
firstPart
,
{
altKey
:
true
});
});
function
prepareKeybindingService
(...
keybindingItems
:
ResolvedKeybindingItem
[]):
ResolvedKeybindingItem
[]
{
instantiationService
.
stub
(
IKeybindingService
,
'
getKeybindings
'
,
()
=>
keybindingItems
);
instantiationService
.
stub
(
IKeybindingService
,
'
getDefaultKeybindings
'
,
()
=>
keybindingItems
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录