Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ff2b4fb0
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,体验更适合开发者的 AI 搜索 >>
提交
ff2b4fb0
编写于
1月 06, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add tests for contextMatchesRules and IOSupport.readKeybindingContexts
上级
884e657d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
61 addition
and
14 deletion
+61
-14
src/vs/platform/keybinding/browser/keybindingServiceImpl.ts
src/vs/platform/keybinding/browser/keybindingServiceImpl.ts
+1
-4
src/vs/platform/keybinding/test/common/keybindingService.test.ts
...platform/keybinding/test/common/keybindingService.test.ts
+49
-1
test/all.js
test/all.js
+11
-9
未找到文件。
src/vs/platform/keybinding/browser/keybindingServiceImpl.ts
浏览文件 @
ff2b4fb0
...
...
@@ -13,10 +13,7 @@ import lifecycle = require('vs/base/common/lifecycle');
import
DOM
=
require
(
'
vs/base/browser/dom
'
);
import
Keyboard
=
require
(
'
vs/base/browser/keyboardEvent
'
);
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
KeybindingsUtils
}
from
'
vs/platform/keybinding/common/keybindingsUtils
'
;
import
strings
=
require
(
'
vs/base/common/strings
'
);
import
Platform
=
require
(
'
vs/base/common/platform
'
);
import
{
IKeybindingService
,
IKeybindingScopeLocation
,
ICommandHandler
,
IKeybindingItem
,
IKeybindings
,
IKeybindingContextRule
,
IUserFriendlyKeybinding
,
IKeybindingContextKey
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
import
{
IKeybindingService
,
IKeybindingScopeLocation
,
ICommandHandler
,
IKeybindingItem
,
IKeybindings
,
IKeybindingContextKey
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
import
{
IResolveResult
,
CommonKeybindingResolver
}
from
'
vs/platform/keybinding/common/commonKeybindingResolver
'
;
...
...
src/vs/platform/keybinding/test/common/keybindingService.test.ts
浏览文件 @
ff2b4fb0
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
assert
=
require
(
'
assert
'
);
import
{
CommonKeybindingResolver
}
from
'
vs/platform/keybinding/common/commonKeybindingResolver
'
;
import
{
CommonKeybindingResolver
,
IOSupport
}
from
'
vs/platform/keybinding/common/commonKeybindingResolver
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
KeybindingsUtils
}
from
'
vs/platform/keybinding/common/keybindingsUtils
'
;
import
Platform
=
require
(
'
vs/base/common/platform
'
);
...
...
@@ -305,7 +305,55 @@ suite('Keybinding Service', () => {
testResolve
({},
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_G
,
'
eleven
'
);
testKey
(
'
sixth
'
,
[]);
});
test
(
'
contextMatchesRules
'
,
function
()
{
function
testExpression
(
expr
:
string
,
expected
:
boolean
):
void
{
let
rules
=
IOSupport
.
readKeybindingContexts
(
expr
);
assert
.
equal
(
CommonKeybindingResolver
.
contextMatchesRules
(
context
,
rules
),
expected
,
expr
);
}
let
context
=
{
'
a
'
:
true
,
'
b
'
:
false
,
'
c
'
:
'
5
'
};
testExpression
(
''
,
true
);
testExpression
(
'
a
'
,
true
);
testExpression
(
'
a == true
'
,
true
==
true
);
testExpression
(
'
a != true
'
,
true
!=
true
);
testExpression
(
'
a == false
'
,
true
==
false
);
testExpression
(
'
a != false
'
,
true
!=
false
);
testExpression
(
'
a == 5
'
,
true
==
<
any
>
'
5
'
);
testExpression
(
'
a != 5
'
,
true
!=
<
any
>
'
5
'
);
testExpression
(
'
!a
'
,
!
true
);
testExpression
(
'
b
'
,
false
);
testExpression
(
'
b == true
'
,
false
==
true
);
testExpression
(
'
b != true
'
,
false
!=
true
);
testExpression
(
'
b == false
'
,
false
==
false
);
testExpression
(
'
b != false
'
,
false
!=
false
);
testExpression
(
'
b == 5
'
,
false
==
<
any
>
'
5
'
);
testExpression
(
'
b != 5
'
,
false
!=
<
any
>
'
5
'
);
testExpression
(
'
!b
'
,
!
false
);
// testExpression('c', <any>'5');
testExpression
(
'
c == true
'
,
<
any
>
'
5
'
==
true
);
testExpression
(
'
c != true
'
,
<
any
>
'
5
'
!=
true
);
testExpression
(
'
c == false
'
,
<
any
>
'
5
'
==
false
);
testExpression
(
'
c != false
'
,
<
any
>
'
5
'
!=
false
);
testExpression
(
'
c == 5
'
,
'
5
'
==
'
5
'
);
testExpression
(
'
c != 5
'
,
'
5
'
!=
'
5
'
);
// testExpression('!c', !'5');
// testExpression('z', undefined);
testExpression
(
'
z == true
'
,
undefined
==
true
);
testExpression
(
'
z != true
'
,
undefined
!=
true
);
// testExpression('z == false', undefined == false);
testExpression
(
'
z != false
'
,
undefined
!=
false
);
testExpression
(
'
z == 5
'
,
undefined
==
<
any
>
'
5
'
);
testExpression
(
'
z != 5
'
,
undefined
!=
<
any
>
'
5
'
);
testExpression
(
'
!z
'
,
!
undefined
);
});
});
test/all.js
浏览文件 @
ff2b4fb0
...
...
@@ -178,16 +178,18 @@ function main() {
});
// replace the default unexpected error handler to be useful during tests
loader
(
'
vs/base/common/errors
'
).
setUnexpectedErrorHandler
(
function
(
err
)
{
try
{
throw
new
Error
(
'
oops
'
);
}
catch
(
e
)
{
unexpectedErrors
.
push
((
err
&&
err
.
message
?
err
.
message
:
err
)
+
'
\n
'
+
e
.
stack
);
}
});
loader
([
'
vs/base/common/errors
'
],
function
(
errors
)
{
errors
.
setUnexpectedErrorHandler
(
function
(
err
)
{
try
{
throw
new
Error
(
'
oops
'
);
}
catch
(
e
)
{
unexpectedErrors
.
push
((
err
&&
err
.
message
?
err
.
message
:
err
)
+
'
\n
'
+
e
.
stack
);
}
});
// fire up mocha
run
();
// fire up mocha
run
();
});
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录