Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
1d2b103b
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,发现更多精彩内容 >>
提交
1d2b103b
编写于
1月 06, 2016
作者:
A
Alex Dima
提交者:
Johannes Rieken
1月 06, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Merge WorkbenchKeybindingService into PluginWorkbenchKeybindingService
上级
5d6e7682
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
90 addition
and
111 deletion
+90
-111
src/vs/workbench/electron-browser/shell.ts
src/vs/workbench/electron-browser/shell.ts
+3
-3
src/vs/workbench/services/keybinding/browser/keybindingService.ts
...orkbench/services/keybinding/browser/keybindingService.ts
+0
-100
src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts
...services/keybinding/electron-browser/keybindingService.ts
+87
-8
未找到文件。
src/vs/workbench/electron-browser/shell.ts
浏览文件 @
1d2b103b
...
...
@@ -40,7 +40,7 @@ import {ConfigurationService} from 'vs/workbench/services/configuration/node/con
import
{
FileService
}
from
'
vs/workbench/services/files/electron-browser/fileService
'
;
import
{
SearchService
}
from
'
vs/workbench/services/search/node/searchService
'
;
import
{
LifecycleService
}
from
'
vs/workbench/services/lifecycle/electron-browser/lifecycleService
'
;
import
PluginWorkbenchKeybindingService
from
'
vs/workbench/services/keybinding/electron-browser/pluginK
eybindingService
'
;
import
{
WorkbenchKeybindingService
}
from
'
vs/workbench/services/keybinding/electron-browser/k
eybindingService
'
;
import
{
MainThreadService
}
from
'
vs/workbench/services/thread/electron-browser/threadService
'
;
import
{
MarkerService
}
from
'
vs/platform/markers/common/markerService
'
;
import
{
IActionsService
}
from
'
vs/platform/actions/common/actions
'
;
...
...
@@ -164,7 +164,7 @@ export class WorkbenchShell {
private
themeService
:
IThemeService
;
private
contextService
:
WorkspaceContextService
;
private
telemetryService
:
ElectronTelemetryService
;
private
keybindingService
:
Plugin
WorkbenchKeybindingService
;
private
keybindingService
:
WorkbenchKeybindingService
;
private
container
:
HTMLElement
;
private
toUnbind
:
{
():
void
;
}[];
...
...
@@ -275,7 +275,7 @@ export class WorkbenchShell {
let
enableTelemetry
=
this
.
configuration
.
env
.
isBuilt
&&
!
this
.
configuration
.
env
.
pluginDevelopmentPath
?
!!
this
.
configuration
.
env
.
enableTelemetry
:
false
;
this
.
telemetryService
=
new
ElectronTelemetryService
(
this
.
storageService
,
{
enableTelemetry
:
enableTelemetry
,
version
:
this
.
configuration
.
env
.
version
,
commitHash
:
this
.
configuration
.
env
.
commitHash
});
this
.
keybindingService
=
new
Plugin
WorkbenchKeybindingService
(
this
.
contextService
,
eventService
,
this
.
telemetryService
,
<
any
>
window
);
this
.
keybindingService
=
new
WorkbenchKeybindingService
(
this
.
contextService
,
eventService
,
this
.
telemetryService
,
<
any
>
window
);
this
.
messageService
=
new
MessageService
(
this
.
contextService
,
this
.
windowService
,
this
.
telemetryService
,
this
.
keybindingService
);
this
.
keybindingService
.
setMessageService
(
this
.
messageService
);
...
...
src/vs/workbench/services/keybinding/browser/keybindingService.ts
已删除
100644 → 0
浏览文件 @
5d6e7682
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
nls
=
require
(
'
vs/nls
'
);
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
KeybindingService
}
from
'
vs/platform/keybinding/browser/keybindingServiceImpl
'
;
import
{
OptionsChangeEvent
,
EventType
}
from
'
vs/workbench/common/events
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IKeybindingItem
,
IUserFriendlyKeybinding
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
import
{
IOSupport
}
from
'
vs/platform/keybinding/common/commonKeybindingResolver
'
;
import
*
as
JSONContributionRegistry
from
'
vs/platform/jsonschemas/common/jsonContributionRegistry
'
;
import
{
IJSONSchema
}
from
'
vs/base/common/jsonSchema
'
;
export
abstract
class
WorkbenchKeybindingService
extends
KeybindingService
{
private
contextService
:
IWorkspaceContextService
;
private
eventService
:
IEventService
;
private
telemetryService
:
ITelemetryService
;
private
toDispose
:
Function
;
constructor
(
contextService
:
IWorkspaceContextService
,
eventService
:
IEventService
,
telemetryService
:
ITelemetryService
,
domNode
:
HTMLElement
)
{
this
.
contextService
=
contextService
;
super
(
domNode
);
this
.
eventService
=
eventService
;
this
.
telemetryService
=
telemetryService
;
this
.
toDispose
=
this
.
eventService
.
addListener
(
EventType
.
WORKBENCH_OPTIONS_CHANGED
,
(
e
)
=>
this
.
onOptionsChanged
(
e
));
}
public
customKeybindingsCount
():
number
{
let
opts
=
this
.
contextService
.
getOptions
();
if
(
opts
.
globalSettings
&&
opts
.
globalSettings
.
keybindings
&&
Array
.
isArray
(
opts
.
globalSettings
.
keybindings
))
{
return
opts
.
globalSettings
.
keybindings
.
length
;
}
return
0
;
}
protected
_getExtraKeybindings
(
isFirstTime
:
boolean
):
IKeybindingItem
[]
{
let
extras
:
IUserFriendlyKeybinding
[]
=
[];
let
opts
=
this
.
contextService
.
getOptions
();
if
(
opts
.
globalSettings
&&
opts
.
globalSettings
.
keybindings
)
{
if
(
!
isFirstTime
)
{
let
cnt
=
0
;
if
(
Array
.
isArray
(
opts
.
globalSettings
.
keybindings
))
{
cnt
=
opts
.
globalSettings
.
keybindings
.
length
;
}
this
.
telemetryService
.
publicLog
(
'
customKeybindingsChanged
'
,
{
keyCount
:
cnt
});
}
if
(
Array
.
isArray
(
opts
.
globalSettings
.
keybindings
))
{
extras
=
opts
.
globalSettings
.
keybindings
;
}
}
return
extras
.
map
((
k
,
i
)
=>
IOSupport
.
readKeybindingItem
(
k
,
i
));
}
private
onOptionsChanged
(
e
:
OptionsChangeEvent
):
void
{
if
(
e
.
key
===
'
globalSettings
'
)
{
this
.
updateResolver
();
}
}
public
dispose
():
void
{
this
.
toDispose
();
}
}
let
schemaId
=
'
local://schemas/keybindings
'
;
let
schema
:
IJSONSchema
=
{
'
id
'
:
schemaId
,
'
type
'
:
'
array
'
,
'
title
'
:
nls
.
localize
(
'
keybindings.json.title
'
,
"
Keybindings configuration
"
),
'
items
'
:
{
'
required
'
:
[
'
key
'
],
'
type
'
:
'
object
'
,
'
default
'
:
{
'
key
'
:
'
{{_}}
'
,
'
command
'
:
'
{{_}}
'
,
'
when
'
:
'
{{_}}
'
},
'
properties
'
:
{
'
key
'
:
{
'
type
'
:
'
string
'
,
'
description
'
:
nls
.
localize
(
'
keybindings.json.key
'
,
'
Key or key sequence (separated by space)
'
),
},
'
command
'
:
{
'
description
'
:
nls
.
localize
(
'
keybindings.json.command
'
,
'
Name of the command to execute
'
),
},
'
when
'
:
{
'
type
'
:
'
string
'
,
'
description
'
:
nls
.
localize
(
'
keybindings.json.when
'
,
'
Condition when the key is active.
'
)
}
}
}
};
let
schemaRegistry
=
<
JSONContributionRegistry
.
IJSONContributionRegistry
>
Registry
.
as
(
JSONContributionRegistry
.
Extensions
.
JSONContribution
);
schemaRegistry
.
registerSchema
(
schemaId
,
schema
);
schemaRegistry
.
addSchemaFileAssociation
(
'
inmemory://defaults/keybindings.json
'
,
schemaId
);
schemaRegistry
.
addSchemaFileAssociation
(
'
%APP_SETTINGS_HOME%/keybindings.json
'
,
schemaId
);
\ No newline at end of file
src/vs/workbench/services/keybinding/electron-browser/
pluginK
eybindingService.ts
→
src/vs/workbench/services/keybinding/electron-browser/
k
eybindingService.ts
浏览文件 @
1d2b103b
...
...
@@ -6,19 +6,23 @@
import
nls
=
require
(
'
vs/nls
'
);
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IJSONSchema
}
from
'
vs/base/common/jsonSchema
'
;
import
{
IHTMLContentElement
}
from
'
vs/base/common/htmlContent
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
IEventService
}
from
'
vs/platform/event/common/event
'
;
import
*
as
JSONContributionRegistry
from
'
vs/platform/jsonschemas/common/jsonContributionRegistry
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
PluginsRegistry
,
IMessageCollector
}
from
'
vs/platform/plugins/common/pluginsRegistry
'
;
import
{
IPluginService
}
from
'
vs/platform/plugins/common/plugins
'
;
import
{
IOSupport
}
from
'
vs/platform/keybinding/common/commonKeybindingResolver
'
;
import
{
WorkbenchKeybindingService
}
from
'
vs/workbench/services/keybinding/browser/keybindingService
'
;
import
{
KeybindingService
}
from
'
vs/platform/keybinding/browser/keybindingServiceImpl
'
;
import
{
IKeybindingItem
,
IUserFriendlyKeybinding
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
import
{
ICommandRule
,
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
IJSONSchema
}
from
'
vs/base/common/jsonSchema
'
;
import
{
Keybinding
,
IKeyBindingLabelProvider
}
from
'
vs/base/common/keyCodes
'
;
import
Platform
=
require
(
'
vs/base/common/platform
'
);
import
{
IHTMLContentElement
}
from
'
vs/base/common/htmlContent
'
;
import
{
Keybinding
}
from
'
vs/base/common/keyCodes
'
;
import
*
as
Platform
from
'
vs/base/common/platform
'
;
import
{
getNativeLabelProvider
}
from
'
vs/workbench/services/keybinding/electron-browser/nativeKeymap
'
;
import
{
OptionsChangeEvent
,
EventType
}
from
'
vs/workbench/common/events
'
;
interface
ContributedKeyBinding
{
command
:
string
;
...
...
@@ -107,14 +111,21 @@ let keybindingsExtPoint = PluginsRegistry.registerExtensionPoint<ContributedKeyB
]
});
export
class
WorkbenchKeybindingService
extends
KeybindingService
{
export
default
class
PluginWorkbenchKeybindingService
extends
WorkbenchKeybindingService
{
private
contextService
:
IWorkspaceContextService
;
private
eventService
:
IEventService
;
private
telemetryService
:
ITelemetryService
;
private
toDispose
:
Function
;
private
_pluginService
:
IPluginService
;
private
_eventService
:
IEventService
;
constructor
(
contextService
:
IWorkspaceContextService
,
eventService
:
IEventService
,
telemetryService
:
ITelemetryService
,
domNode
:
HTMLElement
)
{
super
(
contextService
,
eventService
,
telemetryService
,
domNode
);
this
.
contextService
=
contextService
;
super
(
domNode
);
this
.
eventService
=
eventService
;
this
.
telemetryService
=
telemetryService
;
this
.
toDispose
=
this
.
eventService
.
addListener
(
EventType
.
WORKBENCH_OPTIONS_CHANGED
,
(
e
)
=>
this
.
onOptionsChanged
(
e
));
this
.
_eventService
=
eventService
;
keybindingsExtPoint
.
setHandler
((
extensions
)
=>
{
let
commandAdded
=
false
;
...
...
@@ -133,6 +144,44 @@ export default class PluginWorkbenchKeybindingService extends WorkbenchKeybindin
this
.
_pluginService
=
pluginService
;
}
public
customKeybindingsCount
():
number
{
let
opts
=
this
.
contextService
.
getOptions
();
if
(
opts
.
globalSettings
&&
opts
.
globalSettings
.
keybindings
&&
Array
.
isArray
(
opts
.
globalSettings
.
keybindings
))
{
return
opts
.
globalSettings
.
keybindings
.
length
;
}
return
0
;
}
protected
_getExtraKeybindings
(
isFirstTime
:
boolean
):
IKeybindingItem
[]
{
let
extras
:
IUserFriendlyKeybinding
[]
=
[];
let
opts
=
this
.
contextService
.
getOptions
();
if
(
opts
.
globalSettings
&&
opts
.
globalSettings
.
keybindings
)
{
if
(
!
isFirstTime
)
{
let
cnt
=
0
;
if
(
Array
.
isArray
(
opts
.
globalSettings
.
keybindings
))
{
cnt
=
opts
.
globalSettings
.
keybindings
.
length
;
}
this
.
telemetryService
.
publicLog
(
'
customKeybindingsChanged
'
,
{
keyCount
:
cnt
});
}
if
(
Array
.
isArray
(
opts
.
globalSettings
.
keybindings
))
{
extras
=
opts
.
globalSettings
.
keybindings
;
}
}
return
extras
.
map
((
k
,
i
)
=>
IOSupport
.
readKeybindingItem
(
k
,
i
));
}
private
onOptionsChanged
(
e
:
OptionsChangeEvent
):
void
{
if
(
e
.
key
===
'
globalSettings
'
)
{
this
.
updateResolver
();
}
}
public
dispose
():
void
{
this
.
toDispose
();
}
public
getLabelFor
(
keybinding
:
Keybinding
):
string
{
return
keybinding
.
toCustomLabel
(
getNativeLabelProvider
());
}
...
...
@@ -232,3 +281,33 @@ export default class PluginWorkbenchKeybindingService extends WorkbenchKeybindin
return
desc
;
}
}
let
schemaId
=
'
local://schemas/keybindings
'
;
let
schema
:
IJSONSchema
=
{
'
id
'
:
schemaId
,
'
type
'
:
'
array
'
,
'
title
'
:
nls
.
localize
(
'
keybindings.json.title
'
,
"
Keybindings configuration
"
),
'
items
'
:
{
'
required
'
:
[
'
key
'
],
'
type
'
:
'
object
'
,
'
default
'
:
{
'
key
'
:
'
{{_}}
'
,
'
command
'
:
'
{{_}}
'
,
'
when
'
:
'
{{_}}
'
},
'
properties
'
:
{
'
key
'
:
{
'
type
'
:
'
string
'
,
'
description
'
:
nls
.
localize
(
'
keybindings.json.key
'
,
'
Key or key sequence (separated by space)
'
),
},
'
command
'
:
{
'
description
'
:
nls
.
localize
(
'
keybindings.json.command
'
,
'
Name of the command to execute
'
),
},
'
when
'
:
{
'
type
'
:
'
string
'
,
'
description
'
:
nls
.
localize
(
'
keybindings.json.when
'
,
'
Condition when the key is active.
'
)
}
}
}
};
let
schemaRegistry
=
<
JSONContributionRegistry
.
IJSONContributionRegistry
>
Registry
.
as
(
JSONContributionRegistry
.
Extensions
.
JSONContribution
);
schemaRegistry
.
registerSchema
(
schemaId
,
schema
);
schemaRegistry
.
addSchemaFileAssociation
(
'
inmemory://defaults/keybindings.json
'
,
schemaId
);
schemaRegistry
.
addSchemaFileAssociation
(
'
%APP_SETTINGS_HOME%/keybindings.json
'
,
schemaId
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录