Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d01fcd31
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,发现更多精彩内容 >>
提交
d01fcd31
编写于
8月 06, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move "keyevent to printbale key"-logic into service, removes duplicated code and fixes #55387
上级
2d232419
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
53 addition
and
30 deletion
+53
-30
src/vs/platform/keybinding/common/abstractKeybindingService.ts
...s/platform/keybinding/common/abstractKeybindingService.ts
+15
-1
src/vs/platform/keybinding/common/keybinding.ts
src/vs/platform/keybinding/common/keybinding.ts
+6
-0
src/vs/platform/keybinding/test/common/mockKeybindingService.ts
.../platform/keybinding/test/common/mockKeybindingService.ts
+4
-0
src/vs/platform/list/browser/listService.ts
src/vs/platform/list/browser/listService.ts
+4
-11
src/vs/workbench/parts/outline/electron-browser/outlinePanel.ts
.../workbench/parts/outline/electron-browser/outlinePanel.ts
+3
-18
src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts
...services/keybinding/electron-browser/keybindingService.ts
+21
-0
未找到文件。
src/vs/platform/keybinding/common/abstractKeybindingService.ts
浏览文件 @
d01fcd31
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
{
ResolvedKeybinding
,
Keybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
ResolvedKeybinding
,
Keybinding
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
IDisposable
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
KeybindingResolver
,
IResolveResult
}
from
'
vs/platform/keybinding/common/keybindingResolver
'
;
...
...
@@ -204,4 +204,18 @@ export abstract class AbstractKeybindingService extends Disposable implements IK
return
shouldPreventDefault
;
}
mightProducePrintableCharacter
(
event
:
IKeyboardEvent
):
boolean
{
if
(
event
.
ctrlKey
||
event
.
metaKey
)
{
// ignore ctrl/cmd-combination but not shift/alt-combinatios
return
false
;
}
// weak check for certain ranges. this is properly implemented in a subclass
// with access to the KeyboardMapperFactory.
if
((
event
.
keyCode
>=
KeyCode
.
KEY_A
&&
event
.
keyCode
<=
KeyCode
.
KEY_Z
)
||
(
event
.
keyCode
>=
KeyCode
.
KEY_0
&&
event
.
keyCode
<=
KeyCode
.
KEY_9
))
{
return
true
;
}
return
false
;
}
}
src/vs/platform/keybinding/common/keybinding.ts
浏览文件 @
d01fcd31
...
...
@@ -77,5 +77,11 @@ export interface IKeybindingService {
getKeybindings
():
ResolvedKeybindingItem
[];
customKeybindingsCount
():
number
;
/**
* Will the given key event produce a character that's rendered on screen, e.g. in a
* text box. *Note* that the results of this function can be incorrect.
*/
mightProducePrintableCharacter
(
event
:
IKeyboardEvent
):
boolean
;
}
src/vs/platform/keybinding/test/common/mockKeybindingService.ts
浏览文件 @
d01fcd31
...
...
@@ -124,4 +124,8 @@ export class MockKeybindingService implements IKeybindingService {
dispatchEvent
(
e
:
IKeyboardEvent
,
target
:
IContextKeyServiceTarget
):
boolean
{
return
false
;
}
mightProducePrintableCharacter
(
e
:
IKeyboardEvent
):
boolean
{
return
false
;
}
}
src/vs/platform/list/browser/listService.ts
浏览文件 @
d01fcd31
...
...
@@ -31,6 +31,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import
{
onUnexpectedError
,
canceled
}
from
'
vs/base/common/errors
'
;
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
IKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
export
type
ListWidget
=
List
<
any
>
|
PagedList
<
any
>
|
ITree
;
...
...
@@ -578,7 +579,8 @@ export class HighlightingTreeController extends WorkbenchTreeController {
constructor
(
options
:
IControllerOptions
,
private
readonly
onType
:
()
=>
any
,
@
IConfigurationService
configurationService
:
IConfigurationService
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IKeybindingService
private
readonly
_keybindingService
:
IKeybindingService
,
)
{
super
(
options
,
configurationService
);
}
...
...
@@ -591,16 +593,7 @@ export class HighlightingTreeController extends WorkbenchTreeController {
if
(
this
.
upKeyBindingDispatcher
.
has
(
event
.
keyCode
))
{
return
false
;
}
if
(
event
.
ctrlKey
||
event
.
metaKey
)
{
// ignore ctrl/cmd-combination but not shift/alt-combinatios
return
false
;
}
// crazy -> during keydown focus moves to the input box
// and because of that the keyup event is handled by the
// input field
if
(
event
.
keyCode
>=
KeyCode
.
KEY_A
&&
event
.
keyCode
<=
KeyCode
.
KEY_Z
)
{
// todo@joh this is much weaker than using the KeyboardMapperFactory
// but due to layering-challanges that's not available here...
if
(
this
.
_keybindingService
.
mightProducePrintableCharacter
(
event
))
{
this
.
onType
();
return
true
;
}
...
...
src/vs/workbench/parts/outline/electron-browser/outlinePanel.ts
浏览文件 @
d01fcd31
...
...
@@ -50,7 +50,6 @@ import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewl
import
{
CollapseAction
}
from
'
vs/workbench/browser/viewlet
'
;
import
{
IViewsService
}
from
'
vs/workbench/common/views
'
;
import
{
ACTIVE_GROUP
,
IEditorService
,
SIDE_GROUP
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
KeyboardMapperFactory
}
from
'
vs/workbench/services/keybinding/electron-browser/keybindingService
'
;
import
{
OutlineConfigKeys
,
OutlineViewFiltered
,
OutlineViewFocused
,
OutlineViewId
}
from
'
./outline
'
;
import
{
OutlineController
,
OutlineDataSource
,
OutlineItemComparator
,
OutlineItemCompareType
,
OutlineItemFilter
,
OutlineRenderer
,
OutlineTreeState
}
from
'
../../../../editor/contrib/documentSymbols/outlineTree
'
;
import
{
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
...
...
@@ -256,12 +255,12 @@ export class OutlinePanel extends ViewletPanel {
@
IEditorService
private
readonly
_editorService
:
IEditorService
,
@
IMarkerService
private
readonly
_markerService
:
IMarkerService
,
@
IConfigurationService
private
readonly
_configurationService
:
IConfigurationService
,
@
IKeybindingService
private
readonly
_keybindingService
:
IKeybindingService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IContextMenuService
contextMenuService
:
IContextMenuService
,
)
{
super
(
options
,
keybindingService
,
contextMenuService
,
configurationService
);
super
(
options
,
_
keybindingService
,
contextMenuService
,
configurationService
);
this
.
_outlineViewState
.
restore
(
this
.
_storageService
);
this
.
_contextKeyFocused
=
OutlineViewFocused
.
bindTo
(
contextKeyService
);
this
.
_contextKeyFiltered
=
OutlineViewFiltered
.
bindTo
(
contextKeyService
);
...
...
@@ -326,8 +325,6 @@ export class OutlinePanel extends ViewletPanel {
const
$this
=
this
;
const
controller
=
new
class
extends
OutlineController
{
private
readonly
_mapper
=
KeyboardMapperFactory
.
INSTANCE
;
constructor
()
{
super
({},
$this
.
configurationService
);
}
...
...
@@ -340,22 +337,10 @@ export class OutlinePanel extends ViewletPanel {
if
(
this
.
upKeyBindingDispatcher
.
has
(
event
.
keyCode
))
{
return
false
;
}
if
(
event
.
ctrlKey
||
event
.
metaKey
)
{
// ignore ctrl/cmd-combination but not shift/alt-combinatios
return
false
;
}
// crazy -> during keydown focus moves to the input box
// and because of that the keyup event is handled by the
// input field
const
mapping
=
this
.
_mapper
.
getRawKeyboardMapping
();
if
(
!
mapping
)
{
return
false
;
}
const
keyInfo
=
mapping
[
event
.
code
];
if
(
!
keyInfo
)
{
return
false
;
}
if
(
keyInfo
.
value
)
{
if
(
$this
.
_keybindingService
.
mightProducePrintableCharacter
(
event
))
{
$this
.
_input
.
focus
();
return
true
;
}
...
...
src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts
浏览文件 @
d01fcd31
...
...
@@ -540,6 +540,27 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
let
pretty
=
unboundCommands
.
sort
().
join
(
'
\n
// -
'
);
return
'
//
'
+
nls
.
localize
(
'
unboundCommands
'
,
"
Here are other available commands:
"
)
+
'
\n
// -
'
+
pretty
;
}
mightProducePrintableCharacter
(
event
:
IKeyboardEvent
):
boolean
{
if
(
event
.
ctrlKey
||
event
.
metaKey
)
{
// ignore ctrl/cmd-combination but not shift/alt-combinatios
return
false
;
}
// consult the KeyboardMapperFactory to check the given event for
// a printable value.
const
mapping
=
KeyboardMapperFactory
.
INSTANCE
.
getRawKeyboardMapping
();
if
(
!
mapping
)
{
return
false
;
}
const
keyInfo
=
mapping
[
event
.
code
];
if
(
!
keyInfo
)
{
return
false
;
}
if
(
keyInfo
.
value
)
{
return
true
;
}
return
false
;
}
}
let
schemaId
=
'
vscode://schemas/keybindings
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录