Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
31d62841
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,发现更多精彩内容 >>
提交
31d62841
编写于
5月 03, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Debt: Correct types for ResolvedKeybinding.getParts()
上级
5df5c920
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
113 addition
and
40 deletion
+113
-40
src/vs/base/browser/ui/keybindingLabel/keybindingLabel.ts
src/vs/base/browser/ui/keybindingLabel/keybindingLabel.ts
+7
-7
src/vs/base/common/keyCodes.ts
src/vs/base/common/keyCodes.ts
+21
-2
src/vs/platform/keybinding/common/usLayoutResolvedKeybinding.ts
.../platform/keybinding/common/usLayoutResolvedKeybinding.ts
+21
-3
src/vs/workbench/parts/preferences/common/keybindingsEditorModel.ts
...kbench/parts/preferences/common/keybindingsEditorModel.ts
+22
-22
src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts
...ench/services/keybinding/common/macLinuxKeyboardMapper.ts
+21
-3
src/vs/workbench/services/keybinding/common/windowsKeyboardMapper.ts
...bench/services/keybinding/common/windowsKeyboardMapper.ts
+21
-3
未找到文件。
src/vs/base/browser/ui/keybindingLabel/keybindingLabel.ts
浏览文件 @
31d62841
...
...
@@ -8,7 +8,7 @@ import 'vs/css!./keybindingLabel';
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
equals
}
from
'
vs/base/common/objects
'
;
import
{
OperatingSystem
}
from
'
vs/base/common/platform
'
;
import
{
ResolvedKeybinding
}
from
'
vs/base/common/keyc
odes
'
;
import
{
ResolvedKeybinding
,
ResolvedKeybindingPart
}
from
'
vs/base/common/keyC
odes
'
;
import
{
UILabelProvider
}
from
'
vs/platform/keybinding/common/keybindingLabels
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
...
...
@@ -72,21 +72,21 @@ export class KeybindingLabel implements IDisposable {
this
.
didEverRender
=
true
;
}
private
renderPart
(
parent
:
HTMLElement
,
part
:
ResolvedKeybinding
,
match
:
PartMatches
)
{
private
renderPart
(
parent
:
HTMLElement
,
part
:
ResolvedKeybinding
Part
,
match
:
PartMatches
)
{
const
modifierLabels
=
UILabelProvider
.
modifierLabels
[
this
.
os
];
if
(
part
.
hasCtrlModifier
()
)
{
if
(
part
.
ctrlKey
)
{
this
.
renderKey
(
parent
,
modifierLabels
.
ctrlKey
,
match
&&
match
.
ctrlKey
,
modifierLabels
.
separator
);
}
if
(
part
.
hasShiftModifier
()
)
{
if
(
part
.
shiftKey
)
{
this
.
renderKey
(
parent
,
modifierLabels
.
shiftKey
,
match
&&
match
.
shiftKey
,
modifierLabels
.
separator
);
}
if
(
part
.
hasAltModifier
()
)
{
if
(
part
.
altKey
)
{
this
.
renderKey
(
parent
,
modifierLabels
.
altKey
,
match
&&
match
.
altKey
,
modifierLabels
.
separator
);
}
if
(
part
.
hasMetaModifier
()
)
{
if
(
part
.
metaKey
)
{
this
.
renderKey
(
parent
,
modifierLabels
.
metaKey
,
match
&&
match
.
metaKey
,
modifierLabels
.
separator
);
}
const
keyLabel
=
part
.
getLabelWithoutModifiers
()
;
const
keyLabel
=
part
.
kbLabel
;
if
(
keyLabel
)
{
this
.
renderKey
(
parent
,
keyLabel
,
match
&&
match
.
keyCode
,
''
);
}
...
...
src/vs/base/common/keyCodes.ts
浏览文件 @
31d62841
...
...
@@ -546,8 +546,27 @@ export class ChordKeybinding {
export
type
Keybinding
=
SimpleKeybinding
|
ChordKeybinding
;
export
class
ResolvedKeybindingPart
{
readonly
ctrlKey
:
boolean
;
readonly
shiftKey
:
boolean
;
readonly
altKey
:
boolean
;
readonly
metaKey
:
boolean
;
readonly
kbLabel
:
string
;
readonly
kbAriaLabel
:
string
;
constructor
(
ctrlKey
:
boolean
,
shiftKey
:
boolean
,
altKey
:
boolean
,
metaKey
:
boolean
,
kbLabel
:
string
,
kbAriaLabel
:
string
)
{
this
.
ctrlKey
=
ctrlKey
;
this
.
shiftKey
=
shiftKey
;
this
.
altKey
=
altKey
;
this
.
metaKey
=
metaKey
;
this
.
kbLabel
=
kbLabel
;
this
.
kbAriaLabel
=
kbAriaLabel
;
}
}
/**
* A resolved keybinding.
* A resolved keybinding.
Can be a simple keybinding or a chord keybinding.
*/
export
abstract
class
ResolvedKeybinding
{
/**
...
...
@@ -612,5 +631,5 @@ export abstract class ResolvedKeybinding {
/**
* Returns the firstPart, chordPart of the keybinding
*/
public
abstract
getParts
():
[
ResolvedKeybinding
,
ResolvedKeybinding
];
public
abstract
getParts
():
[
ResolvedKeybinding
Part
,
ResolvedKeybindingPart
];
}
src/vs/platform/keybinding/common/usLayoutResolvedKeybinding.ts
浏览文件 @
31d62841
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
ResolvedKeybinding
,
KeyCode
,
KeyCodeUtils
,
USER_SETTINGS
,
Keybinding
,
KeybindingType
,
SimpleKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
ResolvedKeybinding
,
ResolvedKeybindingPart
,
KeyCode
,
KeyCodeUtils
,
USER_SETTINGS
,
Keybinding
,
KeybindingType
,
SimpleKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
UILabelProvider
,
AriaLabelProvider
,
ElectronAcceleratorLabelProvider
,
UserSettingsLabelProvider
,
NO_MODIFIERS
}
from
'
vs/platform/keybinding/common/keybindingLabels
'
;
import
{
OperatingSystem
}
from
'
vs/base/common/platform
'
;
...
...
@@ -185,8 +185,26 @@ export class USLayoutResolvedKeybinding extends ResolvedKeybinding {
return
this
.
_firstPart
.
metaKey
;
}
public
getParts
():
[
ResolvedKeybinding
,
ResolvedKeybinding
]
{
return
[
new
USLayoutResolvedKeybinding
(
this
.
_firstPart
,
this
.
_os
),
this
.
_chordPart
?
new
USLayoutResolvedKeybinding
(
this
.
_chordPart
,
this
.
_os
)
:
null
];
public
getParts
():
[
ResolvedKeybindingPart
,
ResolvedKeybindingPart
]
{
return
[
this
.
_toResolvedKeybindingPart
(
this
.
_firstPart
),
this
.
_toResolvedKeybindingPart
(
this
.
_chordPart
)
];
}
private
_toResolvedKeybindingPart
(
keybinding
:
SimpleKeybinding
):
ResolvedKeybindingPart
{
if
(
!
keybinding
)
{
return
null
;
}
return
new
ResolvedKeybindingPart
(
keybinding
.
ctrlKey
,
keybinding
.
shiftKey
,
keybinding
.
altKey
,
keybinding
.
metaKey
,
this
.
_getUILabelForKeybinding
(
keybinding
),
this
.
_getAriaLabelForKeybinding
(
keybinding
)
);
}
public
getDispatchParts
():
[
string
,
string
]
{
...
...
src/vs/workbench/parts/preferences/common/keybindingsEditorModel.ts
浏览文件 @
31d62841
...
...
@@ -10,7 +10,7 @@ import * as strings from 'vs/base/common/strings';
import
{
OperatingSystem
,
language
,
LANGUAGE_DEFAULT
}
from
'
vs/base/common/platform
'
;
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
'
;
import
{
ResolvedKeybinding
,
ResolvedKeybindingPart
}
from
'
vs/base/common/keyCodes
'
;
import
{
AriaLabelProvider
,
UserSettingsLabelProvider
,
UILabelProvider
,
ModifierLabels
as
ModLabels
}
from
'
vs/platform/keybinding/common/keybindingLabels
'
;
import
{
CommonEditorRegistry
,
EditorAction
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
MenuRegistry
,
ILocalizedString
,
SyncActionDescriptor
,
ICommandAction
}
from
'
vs/platform/actions/common/actions
'
;
...
...
@@ -355,7 +355,7 @@ class KeybindingItemMatches {
return
this
.
hasAnyMatch
(
firstPartMatch
)
||
this
.
hasAnyMatch
(
chordPartMatch
)
?
{
firstPart
:
firstPartMatch
,
chordPart
:
chordPartMatch
}
:
null
;
}
private
matchPart
(
part
:
ResolvedKeybinding
,
match
:
KeybindingMatch
,
word
:
string
):
boolean
{
private
matchPart
(
part
:
ResolvedKeybinding
Part
,
match
:
KeybindingMatch
,
word
:
string
):
boolean
{
let
matched
=
false
;
if
(
this
.
matchesMetaModifier
(
part
,
word
))
{
matched
=
true
;
...
...
@@ -380,11 +380,11 @@ class KeybindingItemMatches {
return
matched
;
}
private
matchesKeyCode
(
keybinding
:
ResolvedKeybinding
,
word
:
string
):
boolean
{
private
matchesKeyCode
(
keybinding
:
ResolvedKeybinding
Part
,
word
:
string
):
boolean
{
if
(
!
keybinding
)
{
return
false
;
}
const
ariaLabel
=
keybinding
.
getAriaLabelWithoutModifiers
()
;
const
ariaLabel
=
keybinding
.
kbAriaLabel
;
if
(
ariaLabel
.
length
===
1
||
word
.
length
===
1
)
{
if
(
strings
.
compareIgnoreCase
(
ariaLabel
,
word
)
===
0
)
{
return
true
;
...
...
@@ -397,11 +397,11 @@ class KeybindingItemMatches {
return
false
;
}
private
matchesMetaModifier
(
keybinding
:
ResolvedKeybinding
,
word
:
string
):
boolean
{
private
matchesMetaModifier
(
keybinding
:
ResolvedKeybinding
Part
,
word
:
string
):
boolean
{
if
(
!
keybinding
)
{
return
false
;
}
if
(
!
keybinding
.
hasMetaModifier
()
)
{
if
(
!
keybinding
.
metaKey
)
{
return
false
;
}
return
this
.
wordMatchesMetaModifier
(
word
);
...
...
@@ -423,11 +423,11 @@ class KeybindingItemMatches {
return
false
;
}
private
matchesCtrlModifier
(
keybinding
:
ResolvedKeybinding
,
word
:
string
):
boolean
{
private
matchesCtrlModifier
(
keybinding
:
ResolvedKeybinding
Part
,
word
:
string
):
boolean
{
if
(
!
keybinding
)
{
return
false
;
}
if
(
!
keybinding
.
hasCtrlModifier
()
)
{
if
(
!
keybinding
.
ctrlKey
)
{
return
false
;
}
return
this
.
wordMatchesCtrlModifier
(
word
);
...
...
@@ -446,11 +446,11 @@ class KeybindingItemMatches {
return
false
;
}
private
matchesShiftModifier
(
keybinding
:
ResolvedKeybinding
,
word
:
string
):
boolean
{
private
matchesShiftModifier
(
keybinding
:
ResolvedKeybinding
Part
,
word
:
string
):
boolean
{
if
(
!
keybinding
)
{
return
false
;
}
if
(
!
keybinding
.
hasShiftModifier
()
)
{
if
(
!
keybinding
.
shiftKey
)
{
return
false
;
}
return
this
.
wordMatchesShiftModifier
(
word
);
...
...
@@ -469,11 +469,11 @@ class KeybindingItemMatches {
return
false
;
}
private
matchesAltModifier
(
keybinding
:
ResolvedKeybinding
,
word
:
string
):
boolean
{
private
matchesAltModifier
(
keybinding
:
ResolvedKeybinding
Part
,
word
:
string
):
boolean
{
if
(
!
keybinding
)
{
return
false
;
}
if
(
!
keybinding
.
hasAltModifier
()
)
{
if
(
!
keybinding
.
altKey
)
{
return
false
;
}
return
this
.
wordMatchesAltModifier
(
word
);
...
...
@@ -503,42 +503,42 @@ class KeybindingItemMatches {
keybindingMatch
.
keyCode
;
}
private
isCompleteMatch
(
part
:
ResolvedKeybinding
,
match
:
KeybindingMatch
):
boolean
{
private
isCompleteMatch
(
part
:
ResolvedKeybinding
Part
,
match
:
KeybindingMatch
):
boolean
{
if
(
!
part
)
{
return
true
;
}
if
(
!
match
.
keyCode
)
{
return
false
;
}
if
(
part
.
hasMetaModifier
()
&&
!
match
.
metaKey
)
{
if
(
part
.
metaKey
&&
!
match
.
metaKey
)
{
return
false
;
}
if
(
part
.
hasAltModifier
()
&&
!
match
.
altKey
)
{
if
(
part
.
altKey
&&
!
match
.
altKey
)
{
return
false
;
}
if
(
part
.
hasCtrlModifier
()
&&
!
match
.
ctrlKey
)
{
if
(
part
.
ctrlKey
&&
!
match
.
ctrlKey
)
{
return
false
;
}
if
(
part
.
hasShiftModifier
()
&&
!
match
.
shiftKey
)
{
if
(
part
.
shiftKey
&&
!
match
.
shiftKey
)
{
return
false
;
}
return
true
;
}
private
createCompleteMatch
(
part
:
ResolvedKeybinding
):
KeybindingMatch
{
private
createCompleteMatch
(
part
:
ResolvedKeybinding
Part
):
KeybindingMatch
{
let
match
:
KeybindingMatch
=
{};
if
(
part
)
{
match
.
keyCode
=
true
;
if
(
part
.
hasMetaModifier
()
)
{
if
(
part
.
metaKey
)
{
match
.
metaKey
=
true
;
}
if
(
part
.
hasAltModifier
()
)
{
if
(
part
.
altKey
)
{
match
.
altKey
=
true
;
}
if
(
part
.
hasCtrlModifier
()
)
{
if
(
part
.
ctrlKey
)
{
match
.
ctrlKey
=
true
;
}
if
(
part
.
hasShiftModifier
()
)
{
if
(
part
.
shiftKey
)
{
match
.
shiftKey
=
true
;
}
}
...
...
src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts
浏览文件 @
31d62841
...
...
@@ -6,7 +6,7 @@
'
use strict
'
;
import
{
OperatingSystem
}
from
'
vs/base/common/platform
'
;
import
{
KeyCode
,
ResolvedKeybinding
,
KeyCodeUtils
,
SimpleKeybinding
,
Keybinding
,
KeybindingType
,
USER_SETTINGS
}
from
'
vs/base/common/keyCodes
'
;
import
{
KeyCode
,
ResolvedKeybinding
,
KeyCodeUtils
,
SimpleKeybinding
,
Keybinding
,
KeybindingType
,
USER_SETTINGS
,
ResolvedKeybindingPart
}
from
'
vs/base/common/keyCodes
'
;
import
{
ScanCode
,
ScanCodeUtils
,
IMMUTABLE_CODE_TO_KEY_CODE
,
IMMUTABLE_KEY_CODE_TO_CODE
,
ScanCodeBinding
}
from
'
vs/workbench/services/keybinding/common/scanCode
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
import
{
UILabelProvider
,
AriaLabelProvider
,
UserSettingsLabelProvider
,
ElectronAcceleratorLabelProvider
,
NO_MODIFIERS
}
from
'
vs/platform/keybinding/common/keybindingLabels
'
;
...
...
@@ -222,8 +222,26 @@ export class NativeResolvedKeybinding extends ResolvedKeybinding {
return
this
.
_firstPart
.
metaKey
;
}
public
getParts
():
[
ResolvedKeybinding
,
ResolvedKeybinding
]
{
return
[
new
NativeResolvedKeybinding
(
this
.
_mapper
,
this
.
_OS
,
this
.
_firstPart
,
null
),
this
.
_chordPart
?
new
NativeResolvedKeybinding
(
this
.
_mapper
,
this
.
_OS
,
this
.
_chordPart
,
null
)
:
null
];
public
getParts
():
[
ResolvedKeybindingPart
,
ResolvedKeybindingPart
]
{
return
[
this
.
_toResolvedKeybindingPart
(
this
.
_firstPart
),
this
.
_toResolvedKeybindingPart
(
this
.
_chordPart
)
];
}
private
_toResolvedKeybindingPart
(
binding
:
ScanCodeBinding
):
ResolvedKeybindingPart
{
if
(
!
binding
)
{
return
null
;
}
return
new
ResolvedKeybindingPart
(
binding
.
ctrlKey
,
binding
.
shiftKey
,
binding
.
altKey
,
binding
.
metaKey
,
this
.
_getUILabelForScanCodeBinding
(
binding
),
this
.
_getAriaLabelForScanCodeBinding
(
binding
)
);
}
public
getDispatchParts
():
[
string
,
string
]
{
...
...
src/vs/workbench/services/keybinding/common/windowsKeyboardMapper.ts
浏览文件 @
31d62841
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
KeyCode
,
KeyCodeUtils
,
ResolvedKeybinding
,
Keybinding
,
SimpleKeybinding
,
KeybindingType
,
USER_SETTINGS
}
from
'
vs/base/common/keyCodes
'
;
import
{
KeyCode
,
KeyCodeUtils
,
ResolvedKeybinding
,
Keybinding
,
SimpleKeybinding
,
KeybindingType
,
USER_SETTINGS
,
ResolvedKeybindingPart
}
from
'
vs/base/common/keyCodes
'
;
import
{
ScanCode
,
ScanCodeUtils
,
IMMUTABLE_CODE_TO_KEY_CODE
,
ScanCodeBinding
}
from
'
vs/workbench/services/keybinding/common/scanCode
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
import
{
UILabelProvider
,
AriaLabelProvider
,
ElectronAcceleratorLabelProvider
,
UserSettingsLabelProvider
,
NO_MODIFIERS
}
from
'
vs/platform/keybinding/common/keybindingLabels
'
;
...
...
@@ -235,8 +235,26 @@ export class WindowsNativeResolvedKeybinding extends ResolvedKeybinding {
return
this
.
_firstPart
.
metaKey
;
}
public
getParts
():
[
ResolvedKeybinding
,
ResolvedKeybinding
]
{
return
[
new
WindowsNativeResolvedKeybinding
(
this
.
_mapper
,
this
.
_firstPart
,
null
),
this
.
_chordPart
?
new
WindowsNativeResolvedKeybinding
(
this
.
_mapper
,
this
.
_chordPart
,
null
)
:
null
];
public
getParts
():
[
ResolvedKeybindingPart
,
ResolvedKeybindingPart
]
{
return
[
this
.
_toResolvedKeybindingPart
(
this
.
_firstPart
),
this
.
_toResolvedKeybindingPart
(
this
.
_chordPart
)
];
}
private
_toResolvedKeybindingPart
(
keybinding
:
SimpleKeybinding
):
ResolvedKeybindingPart
{
if
(
!
keybinding
)
{
return
null
;
}
return
new
ResolvedKeybindingPart
(
keybinding
.
ctrlKey
,
keybinding
.
shiftKey
,
keybinding
.
altKey
,
keybinding
.
metaKey
,
this
.
_getUILabelForKeybinding
(
keybinding
),
this
.
_getAriaLabelForKeybinding
(
keybinding
)
);
}
public
getDispatchParts
():
[
string
,
string
]
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录