Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
227b38f6
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,体验更适合开发者的 AI 搜索 >>
提交
227b38f6
编写于
5月 19, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #26945: Present symbolic names in keybindings.json for non-US standard keyboard layouts
上级
d33fce1c
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
51 addition
and
48 deletion
+51
-48
src/vs/base/common/keyCodes.ts
src/vs/base/common/keyCodes.ts
+20
-22
src/vs/platform/keybinding/common/usLayoutResolvedKeybinding.ts
.../platform/keybinding/common/usLayoutResolvedKeybinding.ts
+2
-2
src/vs/workbench/services/keybinding/common/keybindingIO.ts
src/vs/workbench/services/keybinding/common/keybindingIO.ts
+3
-3
src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts
...ench/services/keybinding/common/macLinuxKeyboardMapper.ts
+3
-3
src/vs/workbench/services/keybinding/common/windowsKeyboardMapper.ts
...bench/services/keybinding/common/windowsKeyboardMapper.ts
+8
-3
src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts
...services/keybinding/electron-browser/keybindingService.ts
+2
-2
src/vs/workbench/services/keybinding/test/windowsKeyboardMapper.test.ts
...ch/services/keybinding/test/windowsKeyboardMapper.test.ts
+13
-13
未找到文件。
src/vs/base/common/keyCodes.ts
浏览文件 @
227b38f6
...
...
@@ -215,25 +215,25 @@ class KeyCodeStrMap {
this
.
_strToKeyCode
[
str
.
toLowerCase
()]
=
keyCode
;
}
fromKeyCode
(
keyCode
:
KeyCode
):
string
{
keyCodeToStr
(
keyCode
:
KeyCode
):
string
{
return
this
.
_keyCodeToStr
[
keyCode
];
}
t
oKeyCode
(
str
:
string
):
KeyCode
{
strT
oKeyCode
(
str
:
string
):
KeyCode
{
return
this
.
_strToKeyCode
[
str
.
toLowerCase
()]
||
KeyCode
.
Unknown
;
}
}
const
ui
=
new
KeyCodeStrMap
();
const
us
UserSettings
=
new
KeyCodeStrMap
();
const
generalUserSettings
=
new
KeyCodeStrMap
();
const
ui
Map
=
new
KeyCodeStrMap
();
const
us
erSettingsUSMap
=
new
KeyCodeStrMap
();
const
userSettingsGeneralMap
=
new
KeyCodeStrMap
();
(
function
()
{
function
define
(
keyCode
:
KeyCode
,
uiLabel
:
string
,
usUserSettingsLabel
:
string
=
uiLabel
,
generalUserSettingsLabel
:
string
=
usUserSettingsLabel
):
void
{
ui
.
define
(
keyCode
,
uiLabel
);
us
UserSettings
.
define
(
keyCode
,
usUserSettingsLabel
);
generalUserSettings
.
define
(
keyCode
,
generalUserSettingsLabel
);
ui
Map
.
define
(
keyCode
,
uiLabel
);
us
erSettingsUSMap
.
define
(
keyCode
,
usUserSettingsLabel
);
userSettingsGeneralMap
.
define
(
keyCode
,
generalUserSettingsLabel
);
}
define
(
KeyCode
.
Unknown
,
'
unknown
'
);
...
...
@@ -360,24 +360,22 @@ const generalUserSettings = new KeyCodeStrMap();
})();
export
const
USER_SETTINGS
=
{
fromKeyCode
:
(
keyCode
:
KeyCode
)
=>
{
return
usUserSettings
.
fromKeyCode
(
keyCode
);
},
toKeyCode
:
(
str
:
string
)
=>
{
return
usUserSettings
.
toKeyCode
(
str
)
||
generalUserSettings
.
toKeyCode
(
str
);
}
};
export
namespace
KeyCodeUtils
{
export
function
toString
(
keyCode
:
KeyCode
):
string
{
return
ui
.
fromKeyCode
(
keyCode
);
// return STRING.fromKeyCode(keyCode);
return
uiMap
.
keyCodeToStr
(
keyCode
);
}
export
function
fromString
(
key
:
string
):
KeyCode
{
return
ui
.
toKeyCode
(
key
);
// return STRING.toKeyCode(key);
return
uiMap
.
strToKeyCode
(
key
);
}
export
function
toUserSettingsUS
(
keyCode
:
KeyCode
):
string
{
return
userSettingsUSMap
.
keyCodeToStr
(
keyCode
);
}
export
function
toUserSettingsGeneral
(
keyCode
:
KeyCode
):
string
{
return
userSettingsGeneralMap
.
keyCodeToStr
(
keyCode
);
}
export
function
fromUserSettings
(
key
:
string
):
KeyCode
{
return
userSettingsUSMap
.
strToKeyCode
(
key
)
||
userSettingsGeneralMap
.
strToKeyCode
(
key
);
}
}
...
...
src/vs/platform/keybinding/common/usLayoutResolvedKeybinding.ts
浏览文件 @
227b38f6
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
ResolvedKeybinding
,
ResolvedKeybindingPart
,
KeyCode
,
KeyCodeUtils
,
USER_SETTINGS
,
Keybinding
,
KeybindingType
,
SimpleKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
ResolvedKeybinding
,
ResolvedKeybindingPart
,
KeyCode
,
KeyCodeUtils
,
Keybinding
,
KeybindingType
,
SimpleKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
UILabelProvider
,
AriaLabelProvider
,
ElectronAcceleratorLabelProvider
,
UserSettingsLabelProvider
}
from
'
vs/platform/keybinding/common/keybindingLabels
'
;
import
{
OperatingSystem
}
from
'
vs/base/common/platform
'
;
...
...
@@ -127,7 +127,7 @@ export class USLayoutResolvedKeybinding extends ResolvedKeybinding {
if
(
keybinding
.
isDuplicateModifierCase
())
{
return
''
;
}
return
USER_SETTINGS
.
fromKeyCode
(
keybinding
.
keyCode
);
return
KeyCodeUtils
.
toUserSettingsUS
(
keybinding
.
keyCode
);
}
public
getUserSettingsLabel
():
string
{
...
...
src/vs/workbench/services/keybinding/common/keybindingIO.ts
浏览文件 @
227b38f6
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
USER_SETTINGS
,
Keybinding
,
SimpleKeybinding
,
ChordKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
Keybinding
,
SimpleKeybinding
,
ChordKeybinding
,
KeyCodeUtils
}
from
'
vs/base/common/keyCodes
'
;
import
{
OperatingSystem
}
from
'
vs/base/common/platform
'
;
import
{
IUserFriendlyKeybinding
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
...
...
@@ -119,7 +119,7 @@ export class KeybindingIO {
private
static
_readSimpleKeybinding
(
input
:
string
):
[
SimpleKeybinding
,
string
]
{
const
mods
=
this
.
_readModifiers
(
input
);
const
keyCode
=
USER_SETTINGS
.
toKeyCode
(
mods
.
key
);
const
keyCode
=
KeyCodeUtils
.
fromUserSettings
(
mods
.
key
);
return
[
new
SimpleKeybinding
(
mods
.
ctrl
,
mods
.
shift
,
mods
.
alt
,
mods
.
meta
,
keyCode
),
mods
.
remains
];
}
...
...
@@ -148,7 +148,7 @@ export class KeybindingIO {
const
scanCode
=
ScanCodeUtils
.
lowerCaseToEnum
(
strScanCode
);
return
[
new
ScanCodeBinding
(
mods
.
ctrl
,
mods
.
shift
,
mods
.
alt
,
mods
.
meta
,
scanCode
),
mods
.
remains
];
}
const
keyCode
=
USER_SETTINGS
.
toKeyCode
(
mods
.
key
);
const
keyCode
=
KeyCodeUtils
.
fromUserSettings
(
mods
.
key
);
return
[
new
SimpleKeybinding
(
mods
.
ctrl
,
mods
.
shift
,
mods
.
alt
,
mods
.
meta
,
keyCode
),
mods
.
remains
];
}
...
...
src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts
浏览文件 @
227b38f6
...
...
@@ -6,7 +6,7 @@
'
use strict
'
;
import
{
OperatingSystem
}
from
'
vs/base/common/platform
'
;
import
{
KeyCode
,
ResolvedKeybinding
,
KeyCodeUtils
,
SimpleKeybinding
,
Keybinding
,
KeybindingType
,
USER_SETTINGS
,
ResolvedKeybindingPart
}
from
'
vs/base/common/keyCodes
'
;
import
{
KeyCode
,
ResolvedKeybinding
,
KeyCodeUtils
,
SimpleKeybinding
,
Keybinding
,
KeybindingType
,
ResolvedKeybindingPart
}
from
'
vs/base/common/keyCodes
'
;
import
{
ScanCode
,
ScanCodeUtils
,
IMMUTABLE_CODE_TO_KEY_CODE
,
IMMUTABLE_KEY_CODE_TO_CODE
,
ScanCodeBinding
}
from
'
vs/workbench/services/keybinding/common/scanCode
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
import
{
UILabelProvider
,
AriaLabelProvider
,
UserSettingsLabelProvider
,
ElectronAcceleratorLabelProvider
}
from
'
vs/platform/keybinding/common/keybindingLabels
'
;
...
...
@@ -926,7 +926,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
const
immutableKeyCode
=
IMMUTABLE_CODE_TO_KEY_CODE
[
binding
.
scanCode
];
if
(
immutableKeyCode
!==
-
1
)
{
return
USER_SETTINGS
.
fromKeyCode
(
immutableKeyCode
).
toLowerCase
();
return
KeyCodeUtils
.
toUserSettingsUS
(
immutableKeyCode
).
toLowerCase
();
}
// Check if this scanCode always maps to the same keyCode and back
...
...
@@ -937,7 +937,7 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
for
(
let
i
=
0
,
len
=
reverseBindings
.
length
;
i
<
len
;
i
++
)
{
const
reverseBinding
=
reverseBindings
[
i
];
if
(
reverseBinding
.
scanCode
===
binding
.
scanCode
)
{
return
USER_SETTINGS
.
fromKeyCode
(
constantKeyCode
).
toLowerCase
();
return
KeyCodeUtils
.
toUserSettingsUS
(
constantKeyCode
).
toLowerCase
();
}
}
}
...
...
src/vs/workbench/services/keybinding/common/windowsKeyboardMapper.ts
浏览文件 @
227b38f6
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
KeyCode
,
KeyCodeUtils
,
ResolvedKeybinding
,
Keybinding
,
SimpleKeybinding
,
KeybindingType
,
USER_SETTINGS
,
ResolvedKeybindingPart
}
from
'
vs/base/common/keyCodes
'
;
import
{
KeyCode
,
KeyCodeUtils
,
ResolvedKeybinding
,
Keybinding
,
SimpleKeybinding
,
KeybindingType
,
ResolvedKeybindingPart
}
from
'
vs/base/common/keyCodes
'
;
import
{
ScanCode
,
ScanCodeUtils
,
IMMUTABLE_CODE_TO_KEY_CODE
,
ScanCodeBinding
}
from
'
vs/workbench/services/keybinding/common/scanCode
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
import
{
UILabelProvider
,
AriaLabelProvider
,
ElectronAcceleratorLabelProvider
,
UserSettingsLabelProvider
}
from
'
vs/platform/keybinding/common/keybindingLabels
'
;
...
...
@@ -171,7 +171,10 @@ export class WindowsNativeResolvedKeybinding extends ResolvedKeybinding {
if
(
keybinding
.
isDuplicateModifierCase
())
{
return
''
;
}
return
USER_SETTINGS
.
fromKeyCode
(
keybinding
.
keyCode
);
if
(
this
.
_mapper
.
isUSStandard
)
{
return
KeyCodeUtils
.
toUserSettingsUS
(
keybinding
.
keyCode
);
}
return
KeyCodeUtils
.
toUserSettingsGeneral
(
keybinding
.
keyCode
);
}
public
getUserSettingsLabel
():
string
{
...
...
@@ -273,12 +276,14 @@ export class WindowsNativeResolvedKeybinding extends ResolvedKeybinding {
export
class
WindowsKeyboardMapper
implements
IKeyboardMapper
{
public
readonly
isUSStandard
:
boolean
;
private
readonly
_codeInfo
:
IScanCodeMapping
[];
private
readonly
_scanCodeToKeyCode
:
KeyCode
[];
private
readonly
_keyCodeToLabel
:
string
[]
=
[];
private
readonly
_keyCodeExists
:
boolean
[];
constructor
(
rawMappings
:
IWindowsKeyboardMapping
)
{
constructor
(
isUSStandard
:
boolean
,
rawMappings
:
IWindowsKeyboardMapping
)
{
this
.
isUSStandard
=
isUSStandard
;
this
.
_scanCodeToKeyCode
=
[];
this
.
_keyCodeToLabel
=
[];
this
.
_keyCodeExists
=
[];
...
...
src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts
浏览文件 @
227b38f6
...
...
@@ -126,8 +126,9 @@ export class KeyboardMapperFactory {
}
private
static
_createKeyboardMapper
(
isISOKeyboard
:
boolean
,
layoutInfo
:
nativeKeymap
.
IKeyboardLayoutInfo
,
rawMapping
:
nativeKeymap
.
IKeyboardMapping
):
IKeyboardMapper
{
const
isUSStandard
=
KeyboardMapperFactory
.
_isUSStandard
(
layoutInfo
);
if
(
OS
===
OperatingSystem
.
Windows
)
{
return
new
WindowsKeyboardMapper
(
<
IWindowsKeyboardMapping
>
rawMapping
);
return
new
WindowsKeyboardMapper
(
isUSStandard
,
<
IWindowsKeyboardMapping
>
rawMapping
);
}
if
(
Object
.
keys
(
rawMapping
).
length
===
0
)
{
...
...
@@ -143,7 +144,6 @@ export class KeyboardMapperFactory {
}
}
const
isUSStandard
=
KeyboardMapperFactory
.
_isUSStandard
(
layoutInfo
);
return
new
MacLinuxKeyboardMapper
(
isISOKeyboard
,
isUSStandard
,
<
IMacLinuxKeyboardMapping
>
rawMapping
,
OS
);
}
...
...
src/vs/workbench/services/keybinding/test/windowsKeyboardMapper.test.ts
浏览文件 @
227b38f6
...
...
@@ -14,9 +14,9 @@ import { ScanCodeBinding, ScanCode } from 'vs/workbench/services/keybinding/comm
const
WRITE_FILE_IF_DIFFERENT
=
false
;
function
createKeyboardMapper
(
file
:
string
):
TPromise
<
WindowsKeyboardMapper
>
{
function
createKeyboardMapper
(
isUSStandard
:
boolean
,
file
:
string
):
TPromise
<
WindowsKeyboardMapper
>
{
return
readRawMapping
<
IWindowsKeyboardMapping
>
(
file
).
then
((
rawMappings
)
=>
{
return
new
WindowsKeyboardMapper
(
rawMappings
);
return
new
WindowsKeyboardMapper
(
isUSStandard
,
rawMappings
);
});
}
...
...
@@ -29,7 +29,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
let
mapper
:
WindowsKeyboardMapper
;
suiteSetup
((
done
)
=>
{
createKeyboardMapper
(
'
win_de_ch
'
).
then
((
_mapper
)
=>
{
createKeyboardMapper
(
false
,
'
win_de_ch
'
).
then
((
_mapper
)
=>
{
mapper
=
_mapper
;
done
();
},
done
);
...
...
@@ -102,7 +102,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
label
:
'
Ctrl+^
'
,
ariaLabel
:
'
Control+^
'
,
electronAccelerator
:
'
Ctrl+]
'
,
userSettingsLabel
:
'
ctrl+
]
'
,
userSettingsLabel
:
'
ctrl+
oem_6
'
,
isWYSIWYG
:
false
,
isChord
:
false
,
dispatchParts
:
[
'
ctrl+]
'
,
null
],
...
...
@@ -125,7 +125,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
label
:
'
Ctrl+^
'
,
ariaLabel
:
'
Control+^
'
,
electronAccelerator
:
'
Ctrl+]
'
,
userSettingsLabel
:
'
ctrl+
]
'
,
userSettingsLabel
:
'
ctrl+
oem_6
'
,
isWYSIWYG
:
false
,
isChord
:
false
,
dispatchParts
:
[
'
ctrl+]
'
,
null
],
...
...
@@ -141,7 +141,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
label
:
'
Shift+^
'
,
ariaLabel
:
'
Shift+^
'
,
electronAccelerator
:
'
Shift+]
'
,
userSettingsLabel
:
'
shift+
]
'
,
userSettingsLabel
:
'
shift+
oem_6
'
,
isWYSIWYG
:
false
,
isChord
:
false
,
dispatchParts
:
[
'
shift+]
'
,
null
],
...
...
@@ -157,7 +157,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
label
:
'
Ctrl+§
'
,
ariaLabel
:
'
Control+§
'
,
electronAccelerator
:
'
Ctrl+/
'
,
userSettingsLabel
:
'
ctrl+
/
'
,
userSettingsLabel
:
'
ctrl+
oem_2
'
,
isWYSIWYG
:
false
,
isChord
:
false
,
dispatchParts
:
[
'
ctrl+/
'
,
null
],
...
...
@@ -173,7 +173,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
label
:
'
Ctrl+Shift+§
'
,
ariaLabel
:
'
Control+Shift+§
'
,
electronAccelerator
:
'
Ctrl+Shift+/
'
,
userSettingsLabel
:
'
ctrl+shift+
/
'
,
userSettingsLabel
:
'
ctrl+shift+
oem_2
'
,
isWYSIWYG
:
false
,
isChord
:
false
,
dispatchParts
:
[
'
ctrl+shift+/
'
,
null
],
...
...
@@ -189,7 +189,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
label
:
'
Ctrl+K Ctrl+ä
'
,
ariaLabel
:
'
Control+K Control+ä
'
,
electronAccelerator
:
null
,
userSettingsLabel
:
'
ctrl+k ctrl+
\\
'
,
userSettingsLabel
:
'
ctrl+k ctrl+
oem_5
'
,
isWYSIWYG
:
false
,
isChord
:
true
,
dispatchParts
:
[
'
ctrl+K
'
,
'
ctrl+
\\
'
],
...
...
@@ -285,7 +285,7 @@ suite('keyboardMapper - WINDOWS de_ch', () => {
label
:
'
Ctrl+, Ctrl+§
'
,
ariaLabel
:
'
Control+, Control+§
'
,
electronAccelerator
:
null
,
userSettingsLabel
:
'
ctrl+
, ctrl+/
'
,
userSettingsLabel
:
'
ctrl+
oem_comma ctrl+oem_2
'
,
isWYSIWYG
:
false
,
isChord
:
true
,
dispatchParts
:
[
'
ctrl+,
'
,
'
ctrl+/
'
],
...
...
@@ -322,7 +322,7 @@ suite('keyboardMapper - WINDOWS en_us', () => {
let
mapper
:
WindowsKeyboardMapper
;
suiteSetup
((
done
)
=>
{
createKeyboardMapper
(
'
win_en_us
'
).
then
((
_mapper
)
=>
{
createKeyboardMapper
(
true
,
'
win_en_us
'
).
then
((
_mapper
)
=>
{
mapper
=
_mapper
;
done
();
},
done
);
...
...
@@ -412,7 +412,7 @@ suite('keyboardMapper - WINDOWS por_ptb', () => {
let
mapper
:
WindowsKeyboardMapper
;
suiteSetup
((
done
)
=>
{
createKeyboardMapper
(
'
win_por_ptb
'
).
then
((
_mapper
)
=>
{
createKeyboardMapper
(
false
,
'
win_por_ptb
'
).
then
((
_mapper
)
=>
{
mapper
=
_mapper
;
done
();
},
done
);
...
...
@@ -471,7 +471,7 @@ suite('keyboardMapper - WINDOWS por_ptb', () => {
suite
(
'
misc
'
,
()
=>
{
test
(
'
issue #23513: Toggle Sidebar Visibility and Go to Line display same key mapping in Arabic keyboard
'
,
()
=>
{
const
mapper
=
new
WindowsKeyboardMapper
({
const
mapper
=
new
WindowsKeyboardMapper
(
false
,
{
'
KeyB
'
:
{
'
vkey
'
:
'
VK_B
'
,
'
value
'
:
'
لا
'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录