Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a92ddb56
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,发现更多精彩内容 >>
提交
a92ddb56
编写于
3月 20, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
IKeybindingService.resolveKeybinding can return N (>=0) ResolvedKeybinding
上级
82a31e8e
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
65 addition
and
38 deletion
+65
-38
src/vs/editor/browser/standalone/simpleServices.ts
src/vs/editor/browser/standalone/simpleServices.ts
+12
-5
src/vs/platform/keybinding/common/abstractKeybindingService.ts
...s/platform/keybinding/common/abstractKeybindingService.ts
+1
-1
src/vs/platform/keybinding/common/keybinding.ts
src/vs/platform/keybinding/common/keybinding.ts
+4
-1
src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts
.../keybinding/test/common/abstractKeybindingService.test.ts
+3
-3
src/vs/platform/keybinding/test/common/mockKeybindingService.ts
.../platform/keybinding/test/common/mockKeybindingService.ts
+3
-3
src/vs/workbench/parts/extensions/browser/extensionEditor.ts
src/vs/workbench/parts/extensions/browser/extensionEditor.ts
+5
-2
src/vs/workbench/parts/preferences/browser/keybindingsEditorContribution.ts
...arts/preferences/browser/keybindingsEditorContribution.ts
+11
-10
src/vs/workbench/parts/search/browser/searchActions.ts
src/vs/workbench/parts/search/browser/searchActions.ts
+7
-4
src/vs/workbench/parts/search/test/browser/searchActions.test.ts
...workbench/parts/search/test/browser/searchActions.test.ts
+1
-1
src/vs/workbench/parts/update/electron-browser/update.ts
src/vs/workbench/parts/update/electron-browser/update.ts
+6
-2
src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts
...services/keybinding/electron-browser/keybindingService.ts
+12
-6
未找到文件。
src/vs/editor/browser/standalone/simpleServices.ts
浏览文件 @
a92ddb56
...
...
@@ -387,16 +387,23 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
const
item
=
items
[
i
];
const
when
=
(
item
.
when
?
item
.
when
.
normalize
()
:
null
);
const
keybinding
=
item
.
keybinding
;
const
resolvedKeybinding
=
(
keybinding
?
this
.
resolveKeybinding
(
keybinding
)
:
null
);
result
[
resultLen
++
]
=
new
ResolvedKeybindingItem
(
resolvedKeybinding
,
item
.
command
,
item
.
commandArgs
,
when
,
isDefault
);
if
(
!
keybinding
)
{
// This might be a removal keybinding item in user settings => accept it
result
[
resultLen
++
]
=
new
ResolvedKeybindingItem
(
null
,
item
.
command
,
item
.
commandArgs
,
when
,
isDefault
);
}
else
{
const
resolvedKeybindings
=
this
.
resolveKeybinding
(
keybinding
);
for
(
let
j
=
0
;
j
<
resolvedKeybindings
.
length
;
j
++
)
{
result
[
resultLen
++
]
=
new
ResolvedKeybindingItem
(
resolvedKeybindings
[
j
],
item
.
command
,
item
.
commandArgs
,
when
,
isDefault
);
}
}
}
return
result
;
}
public
resolveKeybinding
(
kb
:
Keybinding
):
ResolvedKeybinding
{
return
new
USLayoutResolvedKeybinding
(
kb
,
OS
)
;
public
resolveKeybinding
(
kb
:
Keybinding
):
ResolvedKeybinding
[]
{
return
[
new
USLayoutResolvedKeybinding
(
kb
,
OS
)]
;
}
public
resolveKeyboardEvent
(
keyboardEvent
:
IKeyboardEvent
):
ResolvedKeybinding
{
...
...
@@ -407,7 +414,7 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
keyboardEvent
.
metaKey
,
keyboardEvent
.
keyCode
);
return
this
.
resolveKeybinding
(
keybinding
);
return
this
.
resolveKeybinding
(
keybinding
)
[
0
]
;
}
}
...
...
src/vs/platform/keybinding/common/abstractKeybindingService.ts
浏览文件 @
a92ddb56
...
...
@@ -62,7 +62,7 @@ export abstract class AbstractKeybindingService implements IKeybindingService {
}
protected
abstract
_getResolver
():
KeybindingResolver
;
public
abstract
resolveKeybinding
(
keybinding
:
Keybinding
):
ResolvedKeybinding
;
public
abstract
resolveKeybinding
(
keybinding
:
Keybinding
):
ResolvedKeybinding
[]
;
public
abstract
resolveKeyboardEvent
(
keyboardEvent
:
IKeyboardEvent
):
ResolvedKeybinding
;
public
getDefaultKeybindings
():
string
{
...
...
src/vs/platform/keybinding/common/keybinding.ts
浏览文件 @
a92ddb56
...
...
@@ -44,7 +44,10 @@ export interface IKeybindingService {
onDidUpdateKeybindings
:
Event
<
IKeybindingEvent
>
;
resolveKeybinding
(
keybinding
:
Keybinding
):
ResolvedKeybinding
;
/**
* Returns none, one or many (depending on keyboard layout)!
*/
resolveKeybinding
(
keybinding
:
Keybinding
):
ResolvedKeybinding
[];
resolveKeyboardEvent
(
keyboardEvent
:
IKeyboardEvent
):
ResolvedKeybinding
;
...
...
src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts
浏览文件 @
a92ddb56
...
...
@@ -42,8 +42,8 @@ suite('AbstractKeybindingService', () => {
return
this
.
_resolver
;
}
public
resolveKeybinding
(
kb
:
Keybinding
):
ResolvedKeybinding
{
return
new
USLayoutResolvedKeybinding
(
kb
,
OS
)
;
public
resolveKeybinding
(
kb
:
Keybinding
):
ResolvedKeybinding
[]
{
return
[
new
USLayoutResolvedKeybinding
(
kb
,
OS
)]
;
}
public
resolveKeyboardEvent
(
keyboardEvent
:
IKeyboardEvent
):
ResolvedKeybinding
{
...
...
@@ -54,7 +54,7 @@ suite('AbstractKeybindingService', () => {
keyboardEvent
.
metaKey
,
keyboardEvent
.
keyCode
);
return
this
.
resolveKeybinding
(
keybinding
);
return
this
.
resolveKeybinding
(
keybinding
)
[
0
]
;
}
public
testDispatch
(
kb
:
number
):
boolean
{
...
...
src/vs/platform/keybinding/test/common/mockKeybindingService.ts
浏览文件 @
a92ddb56
...
...
@@ -77,8 +77,8 @@ export class MockKeybindingService implements IKeybindingService {
return
[];
}
public
resolveKeybinding
(
keybinding
:
Keybinding
):
ResolvedKeybinding
{
return
new
USLayoutResolvedKeybinding
(
keybinding
,
OS
)
;
public
resolveKeybinding
(
keybinding
:
Keybinding
):
ResolvedKeybinding
[]
{
return
[
new
USLayoutResolvedKeybinding
(
keybinding
,
OS
)]
;
}
public
resolveKeyboardEvent
(
keyboardEvent
:
IKeyboardEvent
):
ResolvedKeybinding
{
...
...
@@ -89,7 +89,7 @@ export class MockKeybindingService implements IKeybindingService {
keyboardEvent
.
metaKey
,
keyboardEvent
.
keyCode
);
return
this
.
resolveKeybinding
(
keybinding
);
return
this
.
resolveKeybinding
(
keybinding
)
[
0
]
;
}
public
lookupKeybindings
(
commandId
:
string
):
ResolvedKeybinding
[]
{
...
...
src/vs/workbench/parts/extensions/browser/extensionEditor.ts
浏览文件 @
a92ddb56
...
...
@@ -669,8 +669,11 @@ export class ExtensionEditor extends BaseEditor {
}
const
keyBinding
=
createKeybinding
(
KeybindingIO
.
readKeybinding
(
key
||
rawKeyBinding
.
key
,
OS
),
OS
);
const
resolvedKeybinding
=
this
.
keybindingService
.
resolveKeybinding
(
keyBinding
);
const
result
=
resolvedKeybinding
.
getLabel
();
const
resolvedKeybindings
=
this
.
keybindingService
.
resolveKeybinding
(
keyBinding
);
if
(
resolvedKeybindings
.
length
===
0
)
{
return
null
;
}
const
result
=
resolvedKeybindings
[
0
].
getLabel
();
return
result
===
'
unknown
'
?
null
:
result
;
}
...
...
src/vs/workbench/parts/preferences/browser/keybindingsEditorContribution.ts
浏览文件 @
a92ddb56
...
...
@@ -160,20 +160,21 @@ export class DefineKeybindingController implements editorCommon.IEditorContribut
var
m
=
model
.
findMatches
(
regex
,
false
,
true
,
false
,
false
,
false
).
map
(
m
=>
m
.
range
);
let
data
=
m
.
map
((
range
)
=>
{
let
text
=
model
.
getValueInRange
(
range
);
let
strKeybinding
=
text
.
substring
(
1
,
text
.
length
-
1
);
strKeybinding
=
strKeybinding
.
replace
(
/
\\\\
/g
,
'
\\
'
);
let
numKeybinding
=
KeybindingIO
.
readKeybinding
(
strKeybinding
,
OS
);
const
text
=
model
.
getValueInRange
(
range
);
const
strKeybinding
=
text
.
substring
(
1
,
text
.
length
-
1
).
replace
(
/
\\\\
/g
,
'
\\
'
);
const
numKeybinding
=
KeybindingIO
.
readKeybinding
(
strKeybinding
,
OS
);
const
keybinding
=
createKeybinding
(
numKeybinding
,
OS
);
const
usResolvedKeybinding
=
new
USLayoutResolvedKeybinding
(
keybinding
,
OS
);
let
keybinding
=
createKeybinding
(
numKeybinding
,
OS
);
let
resolvedKeybinding
=
this
.
_keybindingService
.
resolveKeybinding
(
keybinding
);
let
label
:
string
=
null
;
const
resolvedKeybindings
=
this
.
_keybindingService
.
resolveKeybinding
(
keybinding
);
if
(
resolvedKeybindings
.
length
>
0
)
{
label
=
resolvedKeybindings
[
0
].
getLabel
();
}
const
usResolvedKeybinding
=
new
USLayoutResolvedKeybinding
(
keybinding
,
OS
);
return
{
usLabel
:
usResolvedKeybinding
.
getLabel
(),
label
:
resolvedKeybinding
.
getLabel
()
,
label
:
label
,
range
:
range
};
});
...
...
src/vs/workbench/parts/search/browser/searchActions.ts
浏览文件 @
a92ddb56
...
...
@@ -39,13 +39,16 @@ export function isSearchViewletFocussed(viewletService: IViewletService): boolea
}
export
function
appendKeyBindingLabel
(
label
:
string
,
keyBinding
:
number
|
ResolvedKeybinding
,
keyBindingService2
:
IKeybindingService
):
string
{
let
resolvedKb
:
ResolvedKeybinding
;
if
(
typeof
keyBinding
===
'
number
'
)
{
resolvedKb
=
keyBindingService2
.
resolveKeybinding
(
createKeybinding
(
keyBinding
,
OS
));
const
resolvedKeybindings
=
keyBindingService2
.
resolveKeybinding
(
createKeybinding
(
keyBinding
,
OS
));
return
doAppendKeyBindingLabel
(
label
,
resolvedKeybindings
.
length
>
0
?
resolvedKeybindings
[
0
]
:
null
);
}
else
{
re
solvedKb
=
keyBinding
;
re
turn
doAppendKeyBindingLabel
(
label
,
keyBinding
)
;
}
return
resolvedKb
?
label
+
'
(
'
+
resolvedKb
.
getLabel
()
+
'
)
'
:
label
;
}
function
doAppendKeyBindingLabel
(
label
:
string
,
keyBinding
:
ResolvedKeybinding
):
string
{
return
keyBinding
?
label
+
'
(
'
+
keyBinding
.
getLabel
()
+
'
)
'
:
label
;
}
export
class
ToggleCaseSensitiveAction
extends
Action
{
...
...
src/vs/workbench/parts/search/test/browser/searchActions.test.ts
浏览文件 @
a92ddb56
...
...
@@ -30,7 +30,7 @@ suite('Search Actions', () => {
instantiationService
=
new
TestInstantiationService
();
instantiationService
.
stub
(
IModelService
,
stubModelService
(
instantiationService
));
instantiationService
.
stub
(
IKeybindingService
,
{});
instantiationService
.
stub
(
IKeybindingService
,
'
resolveKeybinding
'
,
(
keybinding
:
Keybinding
)
=>
new
USLayoutResolvedKeybinding
(
keybinding
,
OS
)
);
instantiationService
.
stub
(
IKeybindingService
,
'
resolveKeybinding
'
,
(
keybinding
:
Keybinding
)
=>
[
new
USLayoutResolvedKeybinding
(
keybinding
,
OS
)]
);
counter
=
0
;
});
...
...
src/vs/workbench/parts/update/electron-browser/update.ts
浏览文件 @
a92ddb56
...
...
@@ -86,9 +86,13 @@ export function loadReleaseNotes(accessor: ServicesAccessor, version: string): T
return
unassigned
;
}
const
resolvedKeybinding
=
keybindingService
.
resolveKeybinding
(
keybinding
);
const
resolvedKeybinding
s
=
keybindingService
.
resolveKeybinding
(
keybinding
);
return
resolvedKeybinding
.
getLabel
();
if
(
resolvedKeybindings
.
length
===
0
)
{
return
unassigned
;
}
return
resolvedKeybindings
[
0
].
getLabel
();
};
return
text
...
...
src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts
浏览文件 @
a92ddb56
...
...
@@ -391,9 +391,15 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
const
item
=
items
[
i
];
const
when
=
(
item
.
when
?
item
.
when
.
normalize
()
:
null
);
const
keybinding
=
item
.
keybinding
;
const
resolvedKeybinding
=
(
keybinding
?
this
.
resolveKeybinding
(
keybinding
)
:
null
);
result
[
resultLen
++
]
=
new
ResolvedKeybindingItem
(
resolvedKeybinding
,
item
.
command
,
item
.
commandArgs
,
when
,
isDefault
);
if
(
!
keybinding
)
{
// This might be a removal keybinding item in user settings => accept it
result
[
resultLen
++
]
=
new
ResolvedKeybindingItem
(
null
,
item
.
command
,
item
.
commandArgs
,
when
,
isDefault
);
}
else
{
const
resolvedKeybindings
=
this
.
resolveKeybinding
(
keybinding
);
for
(
let
j
=
0
;
j
<
resolvedKeybindings
.
length
;
j
++
)
{
result
[
resultLen
++
]
=
new
ResolvedKeybindingItem
(
resolvedKeybindings
[
j
],
item
.
command
,
item
.
commandArgs
,
when
,
isDefault
);
}
}
}
return
result
;
...
...
@@ -412,8 +418,8 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
return
extraUserKeybindings
.
map
((
k
,
i
)
=>
KeybindingIO
.
readKeybindingItem
(
k
,
i
,
OS
));
}
public
resolveKeybinding
(
kb
:
Keybinding
):
ResolvedKeybinding
{
return
new
FancyResolvedKeybinding
(
kb
)
;
public
resolveKeybinding
(
kb
:
Keybinding
):
ResolvedKeybinding
[]
{
return
[
new
FancyResolvedKeybinding
(
kb
)]
;
}
public
resolveKeyboardEvent
(
keyboardEvent
:
IKeyboardEvent
):
ResolvedKeybinding
{
...
...
@@ -424,7 +430,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
keyboardEvent
.
metaKey
,
keyboardEvent
.
keyCode
);
return
this
.
resolveKeybinding
(
keybinding
);
return
this
.
resolveKeybinding
(
keybinding
)
[
0
]
;
}
private
_handleKeybindingsExtensionPointUser
(
isBuiltin
:
boolean
,
keybindings
:
ContributedKeyBinding
|
ContributedKeyBinding
[],
collector
:
ExtensionMessageCollector
):
boolean
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录