Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
fcfec9f8
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fcfec9f8
编写于
3月 29, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #23335: classic keybindings editor shows warning for cmd+shift+_ bindings
上级
3664ebf5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
92 addition
and
2 deletion
+92
-2
src/vs/workbench/parts/preferences/browser/keybindingsEditorContribution.ts
...arts/preferences/browser/keybindingsEditorContribution.ts
+40
-2
src/vs/workbench/parts/preferences/test/browser/keybindingsEditorContribution.test.ts
...rences/test/browser/keybindingsEditorContribution.test.ts
+42
-0
src/vs/workbench/services/keybinding/common/scanCode.ts
src/vs/workbench/services/keybinding/common/scanCode.ts
+10
-0
未找到文件。
src/vs/workbench/parts/preferences/browser/keybindingsEditorContribution.ts
浏览文件 @
fcfec9f8
...
@@ -9,7 +9,7 @@ import * as nls from 'vs/nls';
...
@@ -9,7 +9,7 @@ import * as nls from 'vs/nls';
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
import
{
MarkedString
}
from
'
vs/base/common/htmlContent
'
;
import
{
MarkedString
}
from
'
vs/base/common/htmlContent
'
;
import
{
KeyCode
,
KeyMod
,
KeyChord
}
from
'
vs/base/common/keyCodes
'
;
import
{
KeyCode
,
KeyMod
,
KeyChord
,
SimpleKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
@@ -24,6 +24,8 @@ import { SnippetController } from 'vs/editor/contrib/snippet/common/snippetContr
...
@@ -24,6 +24,8 @@ import { SnippetController } from 'vs/editor/contrib/snippet/common/snippetContr
import
{
SmartSnippetInserter
}
from
'
vs/workbench/parts/preferences/common/smartSnippetInserter
'
;
import
{
SmartSnippetInserter
}
from
'
vs/workbench/parts/preferences/common/smartSnippetInserter
'
;
import
{
DefineKeybindingOverlayWidget
}
from
'
vs/workbench/parts/preferences/browser/keybindingWidgets
'
;
import
{
DefineKeybindingOverlayWidget
}
from
'
vs/workbench/parts/preferences/browser/keybindingWidgets
'
;
import
{
parseTree
,
Node
}
from
'
vs/base/common/json
'
;
import
{
parseTree
,
Node
}
from
'
vs/base/common/json
'
;
import
{
KeybindingIO
}
from
'
vs/workbench/services/keybinding/common/keybindingIO
'
;
import
{
ScanCodeBinding
}
from
'
vs/workbench/services/keybinding/common/scanCode
'
;
import
EditorContextKeys
=
editorCommon
.
EditorContextKeys
;
import
EditorContextKeys
=
editorCommon
.
EditorContextKeys
;
...
@@ -200,7 +202,7 @@ export class DefineKeybindingController implements editorCommon.IEditorContribut
...
@@ -200,7 +202,7 @@ export class DefineKeybindingController implements editorCommon.IEditorContribut
return
this
.
_createDecoration
(
false
,
resolvedKeybinding
.
getLabel
(),
model
,
value
);
return
this
.
_createDecoration
(
false
,
resolvedKeybinding
.
getLabel
(),
model
,
value
);
}
}
const
expectedUserSettingsLabel
=
resolvedKeybinding
.
getUserSettingsLabel
();
const
expectedUserSettingsLabel
=
resolvedKeybinding
.
getUserSettingsLabel
();
if
(
value
.
value
.
trim
().
toLowerCase
()
!==
expectedUserSettingsLabel
.
trim
().
toLowerCase
(
))
{
if
(
!
DefineKeybindingController
.
_userSettingsFuzzyEquals
(
value
.
value
,
expectedUserSettingsLabel
))
{
return
this
.
_createDecoration
(
false
,
resolvedKeybinding
.
getLabel
(),
model
,
value
);
return
this
.
_createDecoration
(
false
,
resolvedKeybinding
.
getLabel
(),
model
,
value
);
}
}
return
null
;
return
null
;
...
@@ -208,6 +210,42 @@ export class DefineKeybindingController implements editorCommon.IEditorContribut
...
@@ -208,6 +210,42 @@ export class DefineKeybindingController implements editorCommon.IEditorContribut
return
null
;
return
null
;
}
}
static
_userSettingsFuzzyEquals
(
a
:
string
,
b
:
string
):
boolean
{
a
=
a
.
trim
().
toLowerCase
();
b
=
b
.
trim
().
toLowerCase
();
if
(
a
===
b
)
{
return
true
;
}
const
[
parsedA1
,
parsedA2
]
=
KeybindingIO
.
_readUserBinding
(
a
);
const
[
parsedB1
,
parsedB2
]
=
KeybindingIO
.
_readUserBinding
(
b
);
return
(
this
.
_userBindingEquals
(
parsedA1
,
parsedB1
)
&&
this
.
_userBindingEquals
(
parsedA2
,
parsedB2
)
);
}
private
static
_userBindingEquals
(
a
:
SimpleKeybinding
|
ScanCodeBinding
,
b
:
SimpleKeybinding
|
ScanCodeBinding
):
boolean
{
if
(
a
===
null
&&
b
===
null
)
{
return
true
;
}
if
(
!
a
||
!
b
)
{
return
false
;
}
if
(
a
instanceof
SimpleKeybinding
&&
b
instanceof
SimpleKeybinding
)
{
return
a
.
equals
(
b
);
}
if
(
a
instanceof
ScanCodeBinding
&&
b
instanceof
ScanCodeBinding
)
{
return
a
.
equals
(
b
);
}
return
false
;
}
private
_createDecoration
(
isError
:
boolean
,
message
:
string
,
model
:
editorCommon
.
IModel
,
keyNode
:
Node
):
editorCommon
.
IModelDeltaDecoration
{
private
_createDecoration
(
isError
:
boolean
,
message
:
string
,
model
:
editorCommon
.
IModel
,
keyNode
:
Node
):
editorCommon
.
IModelDeltaDecoration
{
let
msg
:
MarkedString
[];
let
msg
:
MarkedString
[];
let
className
:
string
;
let
className
:
string
;
...
...
src/vs/workbench/parts/preferences/test/browser/keybindingsEditorContribution.test.ts
0 → 100644
浏览文件 @
fcfec9f8
/*---------------------------------------------------------------------------------------------
* 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
*
as
assert
from
'
assert
'
;
import
{
DefineKeybindingController
}
from
'
vs/workbench/parts/preferences/browser/keybindingsEditorContribution
'
;
suite
(
'
KeybindingsEditorContribution
'
,
()
=>
{
function
assertUserSettingsFuzzyEquals
(
a
:
string
,
b
:
string
,
expected
:
boolean
):
void
{
const
actual
=
DefineKeybindingController
.
_userSettingsFuzzyEquals
(
a
,
b
);
const
message
=
expected
?
`
${
a
}
==
${
b
}
`
:
`
${
a
}
!=
${
b
}
`
;
assert
.
equal
(
actual
,
expected
,
'
fuzzy:
'
+
message
);
}
function
assertEqual
(
a
:
string
,
b
:
string
):
void
{
assertUserSettingsFuzzyEquals
(
a
,
b
,
true
);
}
function
assertDifferent
(
a
:
string
,
b
:
string
):
void
{
assertUserSettingsFuzzyEquals
(
a
,
b
,
false
);
}
test
(
'
_userSettingsFuzzyEquals
'
,
()
=>
{
assertEqual
(
'
a
'
,
'
a
'
);
assertEqual
(
'
a
'
,
'
A
'
);
assertEqual
(
'
ctrl+a
'
,
'
CTRL+A
'
);
assertEqual
(
'
ctrl+a
'
,
'
CTRL+A
'
);
assertEqual
(
'
ctrl+shift+a
'
,
'
shift+ctrl+a
'
);
assertEqual
(
'
ctrl+shift+a ctrl+alt+b
'
,
'
shift+ctrl+a alt+ctrl+b
'
);
assertDifferent
(
'
ctrl+[KeyA]
'
,
'
ctrl+a
'
);
// issue #23335
assertEqual
(
'
cmd+shift+p
'
,
'
shift+cmd+p
'
);
assertEqual
(
'
cmd+shift+p
'
,
'
shift-cmd-p
'
);
});
});
src/vs/workbench/services/keybinding/common/scanCode.ts
浏览文件 @
fcfec9f8
...
@@ -239,6 +239,16 @@ export class ScanCodeBinding {
...
@@ -239,6 +239,16 @@ export class ScanCodeBinding {
this
.
scanCode
=
scanCode
;
this
.
scanCode
=
scanCode
;
}
}
public
equals
(
other
:
ScanCodeBinding
):
boolean
{
return
(
this
.
ctrlKey
===
other
.
ctrlKey
&&
this
.
shiftKey
===
other
.
shiftKey
&&
this
.
altKey
===
other
.
altKey
&&
this
.
metaKey
===
other
.
metaKey
&&
this
.
scanCode
===
other
.
scanCode
);
}
/**
/**
* Does this keybinding refer to the key code of a modifier and it also has the modifier flag?
* Does this keybinding refer to the key code of a modifier and it also has the modifier flag?
*/
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录