Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e95efa55
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,发现更多精彩内容 >>
提交
e95efa55
编写于
3月 17, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move KeybindingIO up to /workbench/
上级
b17d2067
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
116 addition
and
110 deletion
+116
-110
src/vs/editor/test/common/standalone/standaloneBase.test.ts
src/vs/editor/test/common/standalone/standaloneBase.test.ts
+2
-44
src/vs/platform/keybinding/common/abstractKeybindingService.ts
...s/platform/keybinding/common/abstractKeybindingService.ts
+13
-56
src/vs/workbench/parts/extensions/browser/extensionEditor.ts
src/vs/workbench/parts/extensions/browser/extensionEditor.ts
+1
-1
src/vs/workbench/parts/preferences/browser/keybindingsEditorContribution.ts
...arts/preferences/browser/keybindingsEditorContribution.ts
+1
-1
src/vs/workbench/parts/update/electron-browser/update.ts
src/vs/workbench/parts/update/electron-browser/update.ts
+1
-1
src/vs/workbench/services/keybinding/common/keybindingIO.ts
src/vs/workbench/services/keybinding/common/keybindingIO.ts
+0
-0
src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts
...services/keybinding/electron-browser/keybindingService.ts
+54
-2
src/vs/workbench/services/keybinding/test/keybindingIO.test.ts
...s/workbench/services/keybinding/test/keybindingIO.test.ts
+44
-5
未找到文件。
src/vs/editor/test/common/standalone/standaloneBase.test.ts
浏览文件 @
e95efa55
...
...
@@ -6,10 +6,8 @@
import
*
as
assert
from
'
assert
'
;
import
{
KeyCode
as
StandaloneKeyCode
,
Severity
as
StandaloneSeverity
}
from
'
vs/editor/common/standalone/standaloneBase
'
;
import
{
createKeybinding
,
KeyCode
as
RuntimeKeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
KeyCode
as
RuntimeKeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
RuntimeSeverity
from
'
vs/base/common/severity
'
;
import
{
KeybindingIO
}
from
'
vs/platform/keybinding/common/keybindingIO
'
;
import
{
OS
}
from
'
vs/base/common/platform
'
;
suite
(
'
StandaloneBase
'
,
()
=>
{
test
(
'
exports enums correctly
'
,
()
=>
{
...
...
@@ -138,44 +136,4 @@ suite('KeyCode', () => {
assertKeyCode
(
StandaloneKeyCode
.
NUMPAD_DIVIDE
,
RuntimeKeyCode
.
NUMPAD_DIVIDE
);
assertKeyCode
(
StandaloneKeyCode
.
MAX_VALUE
,
RuntimeKeyCode
.
MAX_VALUE
);
});
test
(
'
getUserSettingsKeybindingRegex
'
,
()
=>
{
let
regex
=
new
RegExp
(
KeybindingIO
.
getUserSettingsKeybindingRegex
());
function
testIsGood
(
userSettingsLabel
:
string
,
message
:
string
=
userSettingsLabel
):
void
{
let
userSettings
=
'
"
'
+
userSettingsLabel
.
replace
(
/
\\
/g
,
'
\\\\
'
)
+
'
"
'
;
let
isGood
=
regex
.
test
(
userSettings
);
assert
.
ok
(
isGood
,
message
);
}
// check that all key codes are covered by the regex
let
ignore
:
boolean
[]
=
[];
ignore
[
RuntimeKeyCode
.
Shift
]
=
true
;
ignore
[
RuntimeKeyCode
.
Ctrl
]
=
true
;
ignore
[
RuntimeKeyCode
.
Alt
]
=
true
;
ignore
[
RuntimeKeyCode
.
Meta
]
=
true
;
for
(
let
keyCode
=
RuntimeKeyCode
.
Unknown
+
1
;
keyCode
<
RuntimeKeyCode
.
MAX_VALUE
;
keyCode
++
)
{
if
(
ignore
[
keyCode
])
{
continue
;
}
let
userSettings
=
KeybindingIO
.
writeKeybinding
(
createKeybinding
(
keyCode
),
OS
);
testIsGood
(
userSettings
,
keyCode
+
'
-
'
+
StandaloneKeyCode
[
keyCode
]
+
'
-
'
+
userSettings
);
}
// one modifier
testIsGood
(
'
ctrl+a
'
);
testIsGood
(
'
shift+a
'
);
testIsGood
(
'
alt+a
'
);
testIsGood
(
'
cmd+a
'
);
testIsGood
(
'
meta+a
'
);
testIsGood
(
'
win+a
'
);
// more modifiers
testIsGood
(
'
ctrl+shift+a
'
);
testIsGood
(
'
shift+alt+a
'
);
testIsGood
(
'
ctrl+shift+alt+a
'
);
// chords
testIsGood
(
'
ctrl+a ctrl+a
'
);
});
});
\ No newline at end of file
});
src/vs/platform/keybinding/common/abstractKeybindingService.ts
浏览文件 @
e95efa55
...
...
@@ -6,21 +6,18 @@
import
*
as
nls
from
'
vs/nls
'
;
import
{
IHTMLContentElement
}
from
'
vs/base/common/htmlContent
'
;
import
{
ResolvedKeybinding
,
SimpleKeybinding
,
Keybinding
,
KeyCode
,
KeyCodeUtils
}
from
'
vs/base/common/keyCodes
'
;
import
{
PrintableKeypress
,
UILabelProvider
,
AriaLabelProvider
,
ElectronAcceleratorLabelProvider
}
from
'
vs/platform/keybinding/common/keybindingLabels
'
;
import
{
ResolvedKeybinding
,
SimpleKeybinding
,
Keybinding
,
KeyCode
,
KeyCodeUtils
,
USER_SETTINGS
}
from
'
vs/base/common/keyCodes
'
;
import
{
PrintableKeypress
,
UILabelProvider
,
AriaLabelProvider
,
ElectronAcceleratorLabelProvider
,
UserSettingsLabelProvider
}
from
'
vs/platform/keybinding/common/keybindingLabels
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
{
isFalsyOrEmpty
}
from
'
vs/base/common/arrays
'
;
import
{
ICommandService
,
CommandsRegistry
,
ICommandHandlerDescription
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
KeybindingResolver
,
IResolveResult
}
from
'
vs/platform/keybinding/common/keybindingResolver
'
;
import
{
IKeybindingEvent
,
IKeybindingService
,
IKeybindingItem2
,
KeybindingSource
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IContextKeyService
,
IContextKeyServiceTarget
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IStatusbarService
}
from
'
vs/platform/statusbar/common/statusbar
'
;
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
KeybindingIO
,
OutputBuilder
}
from
'
vs/platform/keybinding/common/keybindingIO
'
;
import
{
NormalizedKeybindingItem
}
from
'
vs/platform/keybinding/common/normalizedKeybindingItem
'
;
import
{
OS
,
OperatingSystem
}
from
'
vs/base/common/platform
'
;
import
{
OperatingSystem
}
from
'
vs/base/common/platform
'
;
/**
* Do not instantiate. Use KeybindingService to get a ResolvedKeybinding seeded with information about the current kb layout.
...
...
@@ -102,8 +99,15 @@ export class USLayoutResolvedKeybinding extends ResolvedKeybinding {
return
ElectronAcceleratorLabelProvider
.
toLabel2
(
firstPart
,
chordPart
,
this
.
_os
);
}
private
static
_usKeyCodeToUserSettings
(
keyCode
:
KeyCode
,
OS
:
OperatingSystem
):
string
{
return
USER_SETTINGS
.
fromKeyCode
(
keyCode
);
}
public
getUserSettingsLabel
():
string
{
return
KeybindingIO
.
writeKeybinding
(
this
.
_actual
,
this
.
_os
);
const
[
firstPart
,
chordPart
]
=
PrintableKeypress
.
fromKeybinding
(
this
.
_actual
,
USLayoutResolvedKeybinding
.
_usKeyCodeToUserSettings
,
this
.
_os
);
let
result
=
UserSettingsLabelProvider
.
toLabel2
(
firstPart
,
chordPart
,
this
.
_os
);
return
result
.
toLowerCase
();
}
}
...
...
@@ -159,14 +163,7 @@ export abstract class AbstractKeybindingService implements IKeybindingService {
}
public
getDefaultKeybindings
():
string
{
const
resolver
=
this
.
_getResolver
();
const
defaultKeybindings
=
resolver
.
getDefaultKeybindings
();
const
boundCommands
=
resolver
.
getDefaultBoundCommands
();
return
(
AbstractKeybindingService
.
_getDefaultKeybindings
(
defaultKeybindings
)
+
'
\n\n
'
+
AbstractKeybindingService
.
_getAllCommandsAsComment
(
boundCommands
)
);
return
''
;
}
public
getKeybindings
():
IKeybindingItem2
[]
{
...
...
@@ -178,46 +175,6 @@ export abstract class AbstractKeybindingService implements IKeybindingService {
}));
}
private
static
_getDefaultKeybindings
(
defaultKeybindings
:
NormalizedKeybindingItem
[]):
string
{
let
out
=
new
OutputBuilder
();
out
.
writeLine
(
'
[
'
);
let
lastIndex
=
defaultKeybindings
.
length
-
1
;
defaultKeybindings
.
forEach
((
k
,
index
)
=>
{
KeybindingIO
.
writeKeybindingItem
(
out
,
k
,
OS
);
if
(
index
!==
lastIndex
)
{
out
.
writeLine
(
'
,
'
);
}
else
{
out
.
writeLine
();
}
});
out
.
writeLine
(
'
]
'
);
return
out
.
toString
();
}
private
static
_getAllCommandsAsComment
(
boundCommands
:
Map
<
string
,
boolean
>
):
string
{
const
commands
=
CommandsRegistry
.
getCommands
();
const
unboundCommands
:
string
[]
=
[];
for
(
let
id
in
commands
)
{
if
(
id
[
0
]
===
'
_
'
||
id
.
indexOf
(
'
vscode.
'
)
===
0
)
{
// private command
continue
;
}
if
(
typeof
commands
[
id
].
description
===
'
object
'
&&
!
isFalsyOrEmpty
((
<
ICommandHandlerDescription
>
commands
[
id
].
description
).
args
))
{
// command with args
continue
;
}
if
(
boundCommands
.
get
(
id
)
===
true
)
{
continue
;
}
unboundCommands
.
push
(
id
);
}
let
pretty
=
unboundCommands
.
sort
().
join
(
'
\n
// -
'
);
return
'
//
'
+
nls
.
localize
(
'
unboundCommands
'
,
"
Here are other available commands:
"
)
+
'
\n
// -
'
+
pretty
;
}
public
customKeybindingsCount
():
number
{
return
0
;
}
...
...
src/vs/workbench/parts/extensions/browser/extensionEditor.ts
浏览文件 @
e95efa55
...
...
@@ -37,7 +37,7 @@ import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import
{
CombinedInstallAction
,
UpdateAction
,
EnableAction
,
DisableAction
,
BuiltinStatusLabelAction
,
ReloadAction
}
from
'
vs/workbench/parts/extensions/browser/extensionsActions
'
;
import
WebView
from
'
vs/workbench/parts/html/browser/webview
'
;
import
{
createKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
KeybindingIO
}
from
'
vs/
platform
/keybinding/common/keybindingIO
'
;
import
{
KeybindingIO
}
from
'
vs/
workbench/services
/keybinding/common/keybindingIO
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
DomScrollableElement
}
from
'
vs/base/browser/ui/scrollbar/scrollableElement
'
;
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
...
...
src/vs/workbench/parts/preferences/browser/keybindingsEditorContribution.ts
浏览文件 @
e95efa55
...
...
@@ -11,7 +11,7 @@ import { RunOnceScheduler } from 'vs/base/common/async';
import
{
MarkedString
}
from
'
vs/base/common/htmlContent
'
;
import
{
createKeybinding
,
KeyCode
,
KeyMod
,
KeyChord
}
from
'
vs/base/common/keyCodes
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
KeybindingIO
}
from
'
vs/
platform
/keybinding/common/keybindingIO
'
;
import
{
KeybindingIO
}
from
'
vs/
workbench/services
/keybinding/common/keybindingIO
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
...
...
src/vs/workbench/parts/update/electron-browser/update.ts
浏览文件 @
e95efa55
...
...
@@ -20,7 +20,7 @@ import { IRequestService } from 'vs/platform/request/node/request';
import
{
asText
}
from
'
vs/base/node/request
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
createKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
KeybindingIO
}
from
'
vs/
platform
/keybinding/common/keybindingIO
'
;
import
{
KeybindingIO
}
from
'
vs/
workbench/services
/keybinding/common/keybindingIO
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
...
...
src/vs/
platform
/keybinding/common/keybindingIO.ts
→
src/vs/
workbench/services
/keybinding/common/keybindingIO.ts
浏览文件 @
e95efa55
文件已移动
src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts
浏览文件 @
e95efa55
...
...
@@ -16,7 +16,8 @@ import { Extensions, IJSONContributionRegistry } from 'vs/platform/jsonschemas/c
import
{
AbstractKeybindingService
,
USLayoutResolvedKeybinding
}
from
'
vs/platform/keybinding/common/abstractKeybindingService
'
;
import
{
IStatusbarService
}
from
'
vs/platform/statusbar/common/statusbar
'
;
import
{
KeybindingResolver
}
from
'
vs/platform/keybinding/common/keybindingResolver
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
isFalsyOrEmpty
}
from
'
vs/base/common/arrays
'
;
import
{
ICommandService
,
CommandsRegistry
,
ICommandHandlerDescription
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IKeybindingEvent
,
IKeybindingItem
,
IUserFriendlyKeybinding
,
KeybindingSource
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
ContextKeyExpr
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IKeybindingRule
,
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
...
...
@@ -30,7 +31,7 @@ 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/normalizedKeybindingItem
'
;
import
{
KeybindingIO
}
from
'
vs/platform
/keybinding/common/keybindingIO
'
;
import
{
KeybindingIO
,
OutputBuilder
}
from
'
vs/workbench/services
/keybinding/common/keybindingIO
'
;
interface
ContributedKeyBinding
{
command
:
string
;
...
...
@@ -338,6 +339,57 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
return
desc
;
}
public
getDefaultKeybindings
():
string
{
const
resolver
=
this
.
_getResolver
();
const
defaultKeybindings
=
resolver
.
getDefaultKeybindings
();
const
boundCommands
=
resolver
.
getDefaultBoundCommands
();
return
(
WorkbenchKeybindingService
.
_getDefaultKeybindings
(
defaultKeybindings
)
+
'
\n\n
'
+
WorkbenchKeybindingService
.
_getAllCommandsAsComment
(
boundCommands
)
);
}
private
static
_getDefaultKeybindings
(
defaultKeybindings
:
NormalizedKeybindingItem
[]):
string
{
let
out
=
new
OutputBuilder
();
out
.
writeLine
(
'
[
'
);
let
lastIndex
=
defaultKeybindings
.
length
-
1
;
defaultKeybindings
.
forEach
((
k
,
index
)
=>
{
KeybindingIO
.
writeKeybindingItem
(
out
,
k
,
OS
);
if
(
index
!==
lastIndex
)
{
out
.
writeLine
(
'
,
'
);
}
else
{
out
.
writeLine
();
}
});
out
.
writeLine
(
'
]
'
);
return
out
.
toString
();
}
private
static
_getAllCommandsAsComment
(
boundCommands
:
Map
<
string
,
boolean
>
):
string
{
const
commands
=
CommandsRegistry
.
getCommands
();
const
unboundCommands
:
string
[]
=
[];
for
(
let
id
in
commands
)
{
if
(
id
[
0
]
===
'
_
'
||
id
.
indexOf
(
'
vscode.
'
)
===
0
)
{
// private command
continue
;
}
if
(
typeof
commands
[
id
].
description
===
'
object
'
&&
!
isFalsyOrEmpty
((
<
ICommandHandlerDescription
>
commands
[
id
].
description
).
args
))
{
// command with args
continue
;
}
if
(
boundCommands
.
get
(
id
)
===
true
)
{
continue
;
}
unboundCommands
.
push
(
id
);
}
let
pretty
=
unboundCommands
.
sort
().
join
(
'
\n
// -
'
);
return
'
//
'
+
nls
.
localize
(
'
unboundCommands
'
,
"
Here are other available commands:
"
)
+
'
\n
// -
'
+
pretty
;
}
}
let
schemaId
=
'
vscode://schemas/keybindings
'
;
...
...
src/vs/
platform/keybinding/test/common
/keybindingIO.test.ts
→
src/vs/
workbench/services/keybinding/test
/keybindingIO.test.ts
浏览文件 @
e95efa55
...
...
@@ -5,13 +5,53 @@
'
use strict
'
;
import
*
as
assert
from
'
assert
'
;
import
{
createKeybinding
,
KeyCode
,
KeyMod
,
KeyChord
}
from
'
vs/base/common/keyCodes
'
;
import
{
createKeybinding
,
KeyCode
,
KeyMod
,
KeyChord
,
KeyCodeUtils
}
from
'
vs/base/common/keyCodes
'
;
import
{
KeybindingIO
}
from
'
vs/workbench/services/keybinding/common/keybindingIO
'
;
import
{
OS
,
OperatingSystem
}
from
'
vs/base/common/platform
'
;
import
{
IUserFriendlyKeybinding
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
NormalizedKeybindingItem
}
from
'
vs/platform/keybinding/common/normalizedKeybindingItem
'
;
import
{
KeybindingIO
}
from
'
vs/platform/keybinding/common/keybindingIO
'
;
import
{
OS
,
OperatingSystem
}
from
'
vs/base/common/platform
'
;
suite
(
'
Keybinding IO
'
,
()
=>
{
suite
(
'
keybindingIO
'
,
()
=>
{
test
(
'
getUserSettingsKeybindingRegex
'
,
()
=>
{
let
regex
=
new
RegExp
(
KeybindingIO
.
getUserSettingsKeybindingRegex
());
function
testIsGood
(
userSettingsLabel
:
string
,
message
:
string
=
userSettingsLabel
):
void
{
let
userSettings
=
'
"
'
+
userSettingsLabel
.
replace
(
/
\\
/g
,
'
\\\\
'
)
+
'
"
'
;
let
isGood
=
regex
.
test
(
userSettings
);
assert
.
ok
(
isGood
,
message
);
}
// check that all key codes are covered by the regex
let
ignore
:
boolean
[]
=
[];
ignore
[
KeyCode
.
Shift
]
=
true
;
ignore
[
KeyCode
.
Ctrl
]
=
true
;
ignore
[
KeyCode
.
Alt
]
=
true
;
ignore
[
KeyCode
.
Meta
]
=
true
;
for
(
let
keyCode
=
KeyCode
.
Unknown
+
1
;
keyCode
<
KeyCode
.
MAX_VALUE
;
keyCode
++
)
{
if
(
ignore
[
keyCode
])
{
continue
;
}
let
userSettings
=
KeybindingIO
.
writeKeybinding
(
createKeybinding
(
keyCode
),
OS
);
testIsGood
(
userSettings
,
keyCode
+
'
-
'
+
KeyCodeUtils
.
toString
(
keyCode
)
+
'
-
'
+
userSettings
);
}
// one modifier
testIsGood
(
'
ctrl+a
'
);
testIsGood
(
'
shift+a
'
);
testIsGood
(
'
alt+a
'
);
testIsGood
(
'
cmd+a
'
);
testIsGood
(
'
meta+a
'
);
testIsGood
(
'
win+a
'
);
// more modifiers
testIsGood
(
'
ctrl+shift+a
'
);
testIsGood
(
'
shift+alt+a
'
);
testIsGood
(
'
ctrl+shift+alt+a
'
);
// chords
testIsGood
(
'
ctrl+a ctrl+a
'
);
});
test
(
'
serialize/deserialize
'
,
function
()
{
...
...
@@ -110,7 +150,6 @@ suite('Keybinding IO', () => {
testDeserialization
(
'
ctrl-shift-alt-win-A
'
,
'
shift-alt-cmd-Ctrl-A
'
,
'
ctrl-shift-alt-META-A
'
,
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyMod
.
Alt
|
KeyMod
.
WinCtrl
|
KeyCode
.
KEY_A
);
});
test
(
'
issue #10452 - invalid command
'
,
()
=>
{
let
strJSON
=
`[{ "key": "ctrl+k ctrl+f", "command": ["firstcommand", "seccondcommand"] }]`
;
let
userKeybinding
=
<
IUserFriendlyKeybinding
>
JSON
.
parse
(
strJSON
)[
0
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录