Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
9db20374
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,发现更多精彩内容 >>
提交
9db20374
编写于
3月 17, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename NormalizedKeybindingItem to ResolvedKeybindingItem
上级
48566c7a
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
43 addition
and
43 deletion
+43
-43
src/vs/editor/browser/standalone/simpleServices.ts
src/vs/editor/browser/standalone/simpleServices.ts
+4
-4
src/vs/platform/keybinding/common/keybindingResolver.ts
src/vs/platform/keybinding/common/keybindingResolver.ts
+21
-21
src/vs/platform/keybinding/common/resolvedKeybindingItem.ts
src/vs/platform/keybinding/common/resolvedKeybindingItem.ts
+2
-2
src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts
.../keybinding/test/common/abstractKeybindingService.test.ts
+5
-5
src/vs/platform/keybinding/test/common/keybindingResolver.test.ts
...latform/keybinding/test/common/keybindingResolver.test.ts
+4
-4
src/vs/workbench/services/keybinding/common/keybindingIO.ts
src/vs/workbench/services/keybinding/common/keybindingIO.ts
+2
-2
src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts
...services/keybinding/electron-browser/keybindingService.ts
+5
-5
未找到文件。
src/vs/editor/browser/standalone/simpleServices.ts
浏览文件 @
9db20374
...
...
@@ -32,7 +32,7 @@ import { MenuId, IMenu, IMenuService } from 'vs/platform/actions/common/actions'
import
{
Menu
}
from
'
vs/platform/actions/common/menu
'
;
import
{
ITelemetryService
,
ITelemetryExperiments
,
ITelemetryInfo
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
ResolvedKeybinding
,
Keybinding
,
createKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
NormalizedKeybindingItem
}
from
'
vs/platform/keybinding/common/normaliz
edKeybindingItem
'
;
import
{
ResolvedKeybindingItem
}
from
'
vs/platform/keybinding/common/resolv
edKeybindingItem
'
;
import
{
OS
}
from
'
vs/base/common/platform
'
;
export
class
SimpleEditor
implements
IEditor
{
...
...
@@ -380,15 +380,15 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
return
this
.
_cachedResolver
;
}
private
_toNormalizedKeybindingItems
(
items
:
IKeybindingItem
[],
isDefault
:
boolean
):
Normaliz
edKeybindingItem
[]
{
let
result
:
Normaliz
edKeybindingItem
[]
=
[],
resultLen
=
0
;
private
_toNormalizedKeybindingItems
(
items
:
IKeybindingItem
[],
isDefault
:
boolean
):
Resolv
edKeybindingItem
[]
{
let
result
:
Resolv
edKeybindingItem
[]
=
[],
resultLen
=
0
;
for
(
let
i
=
0
,
len
=
items
.
length
;
i
<
len
;
i
++
)
{
const
item
=
items
[
i
];
const
when
=
(
item
.
when
?
item
.
when
.
normalize
()
:
null
);
const
keybinding
=
(
item
.
keybinding
!==
0
?
createKeybinding
(
item
.
keybinding
)
:
null
);
const
resolvedKeybinding
=
(
keybinding
!==
null
?
this
.
_createResolvedKeybinding
(
keybinding
)
:
null
);
result
[
resultLen
++
]
=
new
Normaliz
edKeybindingItem
(
resolvedKeybinding
,
item
.
command
,
item
.
commandArgs
,
when
,
isDefault
);
result
[
resultLen
++
]
=
new
Resolv
edKeybindingItem
(
resolvedKeybinding
,
item
.
command
,
item
.
commandArgs
,
when
,
isDefault
);
}
return
result
;
...
...
src/vs/platform/keybinding/common/keybindingResolver.ts
浏览文件 @
9db20374
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
NormalizedKeybindingItem
}
from
'
vs/platform/keybinding/common/normaliz
edKeybindingItem
'
;
import
{
ResolvedKeybindingItem
}
from
'
vs/platform/keybinding/common/resolv
edKeybindingItem
'
;
export
interface
IResolveResult
{
enterChord
:
boolean
;
...
...
@@ -15,14 +15,14 @@ export interface IResolveResult {
}
export
class
KeybindingResolver
{
private
readonly
_defaultKeybindings
:
Normaliz
edKeybindingItem
[];
private
readonly
_keybindings
:
Normaliz
edKeybindingItem
[];
private
readonly
_defaultKeybindings
:
Resolv
edKeybindingItem
[];
private
readonly
_keybindings
:
Resolv
edKeybindingItem
[];
private
readonly
_shouldWarnOnConflict
:
boolean
;
private
readonly
_defaultBoundCommands
:
Map
<
string
,
boolean
>
;
private
readonly
_map
:
Map
<
string
,
Normaliz
edKeybindingItem
[]
>
;
private
readonly
_lookupMap
:
Map
<
string
,
Normaliz
edKeybindingItem
[]
>
;
private
readonly
_map
:
Map
<
string
,
Resolv
edKeybindingItem
[]
>
;
private
readonly
_lookupMap
:
Map
<
string
,
Resolv
edKeybindingItem
[]
>
;
constructor
(
defaultKeybindings
:
NormalizedKeybindingItem
[],
overrides
:
Normaliz
edKeybindingItem
[],
shouldWarnOnConflict
:
boolean
=
true
)
{
constructor
(
defaultKeybindings
:
ResolvedKeybindingItem
[],
overrides
:
Resolv
edKeybindingItem
[],
shouldWarnOnConflict
:
boolean
=
true
)
{
this
.
_defaultKeybindings
=
defaultKeybindings
;
this
.
_shouldWarnOnConflict
=
shouldWarnOnConflict
;
...
...
@@ -32,8 +32,8 @@ export class KeybindingResolver {
this
.
_defaultBoundCommands
.
set
(
command
,
true
);
}
this
.
_map
=
new
Map
<
string
,
Normaliz
edKeybindingItem
[]
>
();
this
.
_lookupMap
=
new
Map
<
string
,
Normaliz
edKeybindingItem
[]
>
();
this
.
_map
=
new
Map
<
string
,
Resolv
edKeybindingItem
[]
>
();
this
.
_lookupMap
=
new
Map
<
string
,
Resolv
edKeybindingItem
[]
>
();
this
.
_keybindings
=
KeybindingResolver
.
combine
(
defaultKeybindings
,
overrides
);
for
(
let
i
=
0
,
len
=
this
.
_keybindings
.
length
;
i
<
len
;
i
++
)
{
...
...
@@ -47,7 +47,7 @@ export class KeybindingResolver {
}
}
private
static
_isTargetedForRemoval
(
defaultKb
:
Normaliz
edKeybindingItem
,
keypressFirstPart
:
string
,
keypressChordPart
:
string
,
command
:
string
,
when
:
ContextKeyExpr
):
boolean
{
private
static
_isTargetedForRemoval
(
defaultKb
:
Resolv
edKeybindingItem
,
keypressFirstPart
:
string
,
keypressChordPart
:
string
,
command
:
string
,
when
:
ContextKeyExpr
):
boolean
{
if
(
defaultKb
.
command
!==
command
)
{
return
false
;
}
...
...
@@ -72,9 +72,9 @@ export class KeybindingResolver {
/**
* Looks for rules containing -command in `overrides` and removes them directly from `defaults`.
*/
public
static
combine
(
defaults
:
NormalizedKeybindingItem
[],
rawOverrides
:
NormalizedKeybindingItem
[]):
Normaliz
edKeybindingItem
[]
{
public
static
combine
(
defaults
:
ResolvedKeybindingItem
[],
rawOverrides
:
ResolvedKeybindingItem
[]):
Resolv
edKeybindingItem
[]
{
defaults
=
defaults
.
slice
(
0
);
let
overrides
:
Normaliz
edKeybindingItem
[]
=
[];
let
overrides
:
Resolv
edKeybindingItem
[]
=
[];
for
(
let
i
=
0
,
len
=
rawOverrides
.
length
;
i
<
len
;
i
++
)
{
const
override
=
rawOverrides
[
i
];
if
(
!
override
.
command
||
override
.
command
.
length
===
0
||
override
.
command
.
charAt
(
0
)
!==
'
-
'
)
{
...
...
@@ -95,7 +95,7 @@ export class KeybindingResolver {
return
defaults
.
concat
(
overrides
);
}
private
_addKeyPress
(
keypress
:
string
,
item
:
Normaliz
edKeybindingItem
):
void
{
private
_addKeyPress
(
keypress
:
string
,
item
:
Resolv
edKeybindingItem
):
void
{
const
conflicts
=
this
.
_map
.
get
(
keypress
);
...
...
@@ -136,7 +136,7 @@ export class KeybindingResolver {
this
.
_addToLookupMap
(
item
);
}
private
_addToLookupMap
(
item
:
Normaliz
edKeybindingItem
):
void
{
private
_addToLookupMap
(
item
:
Resolv
edKeybindingItem
):
void
{
if
(
!
item
.
command
)
{
return
;
}
...
...
@@ -150,7 +150,7 @@ export class KeybindingResolver {
}
}
private
_removeFromLookupMap
(
item
:
Normaliz
edKeybindingItem
):
void
{
private
_removeFromLookupMap
(
item
:
Resolv
edKeybindingItem
):
void
{
let
arr
=
this
.
_lookupMap
.
get
(
item
.
command
);
if
(
typeof
arr
===
'
undefined
'
)
{
return
;
...
...
@@ -201,29 +201,29 @@ export class KeybindingResolver {
return
this
.
_defaultBoundCommands
;
}
public
getDefaultKeybindings
():
Normaliz
edKeybindingItem
[]
{
public
getDefaultKeybindings
():
Resolv
edKeybindingItem
[]
{
return
this
.
_defaultKeybindings
;
}
public
getKeybindings
():
Normaliz
edKeybindingItem
[]
{
public
getKeybindings
():
Resolv
edKeybindingItem
[]
{
return
this
.
_keybindings
;
}
public
lookupKeybindings
(
commandId
:
string
):
Normaliz
edKeybindingItem
[]
{
public
lookupKeybindings
(
commandId
:
string
):
Resolv
edKeybindingItem
[]
{
let
items
=
this
.
_lookupMap
.
get
(
commandId
);
if
(
typeof
items
===
'
undefined
'
||
items
.
length
===
0
)
{
return
[];
}
// Reverse to get the most specific item first
let
result
:
Normaliz
edKeybindingItem
[]
=
[],
resultLen
=
0
;
let
result
:
Resolv
edKeybindingItem
[]
=
[],
resultLen
=
0
;
for
(
let
i
=
items
.
length
-
1
;
i
>=
0
;
i
--
)
{
result
[
resultLen
++
]
=
items
[
i
];
}
return
result
;
}
public
lookupPrimaryKeybinding
(
commandId
:
string
):
Normaliz
edKeybindingItem
{
public
lookupPrimaryKeybinding
(
commandId
:
string
):
Resolv
edKeybindingItem
{
let
items
=
this
.
_lookupMap
.
get
(
commandId
);
if
(
typeof
items
===
'
undefined
'
||
items
.
length
===
0
)
{
return
null
;
...
...
@@ -233,7 +233,7 @@ export class KeybindingResolver {
}
public
resolve
(
context
:
any
,
currentChord
:
string
,
keypress
:
string
):
IResolveResult
{
let
lookupMap
:
Normaliz
edKeybindingItem
[]
=
null
;
let
lookupMap
:
Resolv
edKeybindingItem
[]
=
null
;
if
(
currentChord
!==
null
)
{
// Fetch all chord bindings for `currentChord`
...
...
@@ -283,7 +283,7 @@ export class KeybindingResolver {
};
}
private
_findCommand
(
context
:
any
,
matches
:
NormalizedKeybindingItem
[]):
Normaliz
edKeybindingItem
{
private
_findCommand
(
context
:
any
,
matches
:
ResolvedKeybindingItem
[]):
Resolv
edKeybindingItem
{
for
(
let
i
=
matches
.
length
-
1
;
i
>=
0
;
i
--
)
{
let
k
=
matches
[
i
];
...
...
src/vs/platform/keybinding/common/
normaliz
edKeybindingItem.ts
→
src/vs/platform/keybinding/common/
resolv
edKeybindingItem.ts
浏览文件 @
9db20374
...
...
@@ -8,8 +8,8 @@ import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
export
class
Normaliz
edKeybindingItem
{
_
normaliz
edKeybindingItemBrand
:
void
;
export
class
Resolv
edKeybindingItem
{
_
resolv
edKeybindingItemBrand
:
void
;
public
readonly
resolvedKeybinding
:
ResolvedKeybinding
;
public
readonly
keypressFirstPart
:
string
;
...
...
src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts
浏览文件 @
9db20374
...
...
@@ -15,7 +15,7 @@ import { ContextKeyExpr, IContextKeyService, IContextKeyServiceTarget } from 'vs
import
{
IStatusbarService
}
from
'
vs/platform/statusbar/common/statusbar
'
;
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
NormalizedKeybindingItem
}
from
'
vs/platform/keybinding/common/normaliz
edKeybindingItem
'
;
import
{
ResolvedKeybindingItem
}
from
'
vs/platform/keybinding/common/resolv
edKeybindingItem
'
;
import
{
OS
}
from
'
vs/base/common/platform
'
;
suite
(
'
AbstractKeybindingService
'
,
()
=>
{
...
...
@@ -47,7 +47,7 @@ suite('AbstractKeybindingService', () => {
}
}
let
createTestKeybindingService
:
(
items
:
Normaliz
edKeybindingItem
[],
contextValue
?:
any
)
=>
TestKeybindingService
=
null
;
let
createTestKeybindingService
:
(
items
:
Resolv
edKeybindingItem
[],
contextValue
?:
any
)
=>
TestKeybindingService
=
null
;
let
currentContextValue
:
any
=
null
;
let
executeCommandCalls
:
{
commandId
:
string
;
args
:
any
[];
}[]
=
null
;
let
showMessageCalls
:
{
sev
:
Severity
,
message
:
any
;
}[]
=
null
;
...
...
@@ -60,7 +60,7 @@ suite('AbstractKeybindingService', () => {
statusMessageCalls
=
[];
statusMessageCallsDisposed
=
[];
createTestKeybindingService
=
(
items
:
Normaliz
edKeybindingItem
[]):
TestKeybindingService
=>
{
createTestKeybindingService
=
(
items
:
Resolv
edKeybindingItem
[]):
TestKeybindingService
=>
{
let
contextKeyService
:
IContextKeyService
=
{
_serviceBrand
:
undefined
,
...
...
@@ -128,9 +128,9 @@ suite('AbstractKeybindingService', () => {
statusMessageCallsDisposed
=
null
;
});
function
kbItem
(
keybinding
:
number
,
command
:
string
,
when
:
ContextKeyExpr
=
null
):
Normaliz
edKeybindingItem
{
function
kbItem
(
keybinding
:
number
,
command
:
string
,
when
:
ContextKeyExpr
=
null
):
Resolv
edKeybindingItem
{
const
resolvedKeybinding
=
(
keybinding
!==
0
?
new
USLayoutResolvedKeybinding
(
createKeybinding
(
keybinding
),
OS
)
:
null
);
return
new
Normaliz
edKeybindingItem
(
return
new
Resolv
edKeybindingItem
(
resolvedKeybinding
,
command
,
null
,
...
...
src/vs/platform/keybinding/test/common/keybindingResolver.test.ts
浏览文件 @
9db20374
...
...
@@ -8,15 +8,15 @@ import * as assert from 'assert';
import
{
createKeybinding
,
SimpleKeybinding
,
KeyCode
,
KeyMod
,
KeyChord
}
from
'
vs/base/common/keyCodes
'
;
import
{
KeybindingResolver
}
from
'
vs/platform/keybinding/common/keybindingResolver
'
;
import
{
ContextKeyAndExpr
,
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
NormalizedKeybindingItem
}
from
'
vs/platform/keybinding/common/normaliz
edKeybindingItem
'
;
import
{
ResolvedKeybindingItem
}
from
'
vs/platform/keybinding/common/resolv
edKeybindingItem
'
;
import
{
USLayoutResolvedKeybinding
}
from
'
vs/platform/keybinding/common/abstractKeybindingService
'
;
import
{
OS
}
from
'
vs/base/common/platform
'
;
suite
(
'
KeybindingResolver
'
,
()
=>
{
function
kbItem
(
keybinding
:
number
,
command
:
string
,
commandArgs
:
any
,
when
:
ContextKeyExpr
,
isDefault
:
boolean
):
Normaliz
edKeybindingItem
{
function
kbItem
(
keybinding
:
number
,
command
:
string
,
commandArgs
:
any
,
when
:
ContextKeyExpr
,
isDefault
:
boolean
):
Resolv
edKeybindingItem
{
const
resolvedKeybinding
=
(
keybinding
!==
0
?
new
USLayoutResolvedKeybinding
(
createKeybinding
(
keybinding
),
OS
)
:
null
);
return
new
Normaliz
edKeybindingItem
(
return
new
Resolv
edKeybindingItem
(
resolvedKeybinding
,
command
,
commandArgs
,
...
...
@@ -232,7 +232,7 @@ suite('KeybindingResolver', () => {
test
(
'
resolve command
'
,
function
()
{
function
_kbItem
(
keybinding
:
number
,
command
:
string
,
when
:
ContextKeyExpr
):
Normaliz
edKeybindingItem
{
function
_kbItem
(
keybinding
:
number
,
command
:
string
,
when
:
ContextKeyExpr
):
Resolv
edKeybindingItem
{
return
kbItem
(
keybinding
,
command
,
null
,
when
,
true
);
}
...
...
src/vs/workbench/services/keybinding/common/keybindingIO.ts
浏览文件 @
9db20374
...
...
@@ -8,11 +8,11 @@ import { KeyMod, KeyChord, USER_SETTINGS } from 'vs/base/common/keyCodes';
import
{
OperatingSystem
}
from
'
vs/base/common/platform
'
;
import
{
IKeybindingItem
,
IUserFriendlyKeybinding
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
NormalizedKeybindingItem
}
from
'
vs/platform/keybinding/common/normaliz
edKeybindingItem
'
;
import
{
ResolvedKeybindingItem
}
from
'
vs/platform/keybinding/common/resolv
edKeybindingItem
'
;
export
class
KeybindingIO
{
public
static
writeKeybindingItem
(
out
:
OutputBuilder
,
item
:
Normaliz
edKeybindingItem
,
OS
:
OperatingSystem
):
void
{
public
static
writeKeybindingItem
(
out
:
OutputBuilder
,
item
:
Resolv
edKeybindingItem
,
OS
:
OperatingSystem
):
void
{
let
quotedSerializedKeybinding
=
JSON
.
stringify
(
item
.
resolvedKeybinding
.
getUserSettingsLabel
());
out
.
write
(
`{ "key":
${
rightPaddedString
(
quotedSerializedKeybinding
+
'
,
'
,
25
)}
"command": `
);
...
...
src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts
浏览文件 @
9db20374
...
...
@@ -30,7 +30,7 @@ import { ConfigWatcher } from 'vs/base/node/config';
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
NormalizedKeybindingItem
}
from
'
vs/platform/keybinding/common/normaliz
edKeybindingItem
'
;
import
{
ResolvedKeybindingItem
}
from
'
vs/platform/keybinding/common/resolv
edKeybindingItem
'
;
import
{
KeybindingIO
,
OutputBuilder
}
from
'
vs/workbench/services/keybinding/common/keybindingIO
'
;
interface
ContributedKeyBinding
{
...
...
@@ -321,15 +321,15 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
return
this
.
_cachedResolver
;
}
private
_toNormalizedKeybindingItems
(
items
:
IKeybindingItem
[],
isDefault
:
boolean
):
Normaliz
edKeybindingItem
[]
{
let
result
:
Normaliz
edKeybindingItem
[]
=
[],
resultLen
=
0
;
private
_toNormalizedKeybindingItems
(
items
:
IKeybindingItem
[],
isDefault
:
boolean
):
Resolv
edKeybindingItem
[]
{
let
result
:
Resolv
edKeybindingItem
[]
=
[],
resultLen
=
0
;
for
(
let
i
=
0
,
len
=
items
.
length
;
i
<
len
;
i
++
)
{
const
item
=
items
[
i
];
const
when
=
(
item
.
when
?
item
.
when
.
normalize
()
:
null
);
const
keybinding
=
(
item
.
keybinding
!==
0
?
createKeybinding
(
item
.
keybinding
)
:
null
);
const
resolvedKeybinding
=
(
keybinding
!==
null
?
this
.
_createResolvedKeybinding
(
keybinding
)
:
null
);
result
[
resultLen
++
]
=
new
Normaliz
edKeybindingItem
(
resolvedKeybinding
,
item
.
command
,
item
.
commandArgs
,
when
,
isDefault
);
result
[
resultLen
++
]
=
new
Resolv
edKeybindingItem
(
resolvedKeybinding
,
item
.
command
,
item
.
commandArgs
,
when
,
isDefault
);
}
return
result
;
...
...
@@ -428,7 +428,7 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
);
}
private
static
_getDefaultKeybindings
(
defaultKeybindings
:
Normaliz
edKeybindingItem
[]):
string
{
private
static
_getDefaultKeybindings
(
defaultKeybindings
:
Resolv
edKeybindingItem
[]):
string
{
let
out
=
new
OutputBuilder
();
out
.
writeLine
(
'
[
'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录