提交 9ff9e802 编写于 作者: A Alex Dima

Fixes #24361: Hotkey hints are not displayed in English

上级 cf5c7cf6
......@@ -309,6 +309,8 @@ export class WindowsKeyboardMapper implements IKeyboardMapper {
}
}
let producesLetter: boolean[] = [];
this._codeInfo = [];
for (let strCode in rawMappings) {
if (rawMappings.hasOwnProperty(strCode)) {
......@@ -347,25 +349,76 @@ export class WindowsKeyboardMapper implements IKeyboardMapper {
withShiftAltGr: withShiftAltGr,
};
this._codeInfo[scanCode] = mapping;
this._scanCodeToKeyCode[scanCode] = keyCode;
if (keyCode === KeyCode.Unknown) {
continue;
}
this._keyCodeExists[keyCode] = true;
if (value.length === 0) {
// This key does not produce strings
this._keyCodeToLabel[keyCode] = null;
}
else if (value.length > 1) {
// This key produces a letter representable with multiple UTF-16 code units.
this._keyCodeToLabel[keyCode] = value;
}
if (keyCode !== KeyCode.Unknown) {
this._keyCodeExists[keyCode] = true;
if (value.length === 0) {
this._keyCodeToLabel[keyCode] = null;
} else if (value.length === 1) {
const charCode = value.charCodeAt(0);
if (charCode >= CharCode.a && charCode <= CharCode.z) {
this._keyCodeToLabel[keyCode] = String.fromCharCode(CharCode.A + (charCode - CharCode.a));
} else {
this._keyCodeToLabel[keyCode] = value;
}
} else {
else {
const charCode = value.charCodeAt(0);
if (charCode >= CharCode.a && charCode <= CharCode.z) {
const upperCaseValue = CharCode.A + (charCode - CharCode.a);
producesLetter[upperCaseValue] = true;
this._keyCodeToLabel[keyCode] = String.fromCharCode(CharCode.A + (charCode - CharCode.a));
}
else if (charCode >= CharCode.A && charCode <= CharCode.Z) {
producesLetter[charCode] = true;
this._keyCodeToLabel[keyCode] = value;
}
else {
this._keyCodeToLabel[keyCode] = value;
}
}
this._scanCodeToKeyCode[scanCode] = keyCode;
}
}
// Handle keyboard layouts where latin characters are not produced e.g. Cyrillic
const _registerLetterIfMissing = (charCode: CharCode, keyCode: KeyCode): void => {
if (!producesLetter[charCode]) {
this._keyCodeToLabel[keyCode] = String.fromCharCode(charCode);
}
};
_registerLetterIfMissing(CharCode.A, KeyCode.KEY_A);
_registerLetterIfMissing(CharCode.B, KeyCode.KEY_B);
_registerLetterIfMissing(CharCode.C, KeyCode.KEY_C);
_registerLetterIfMissing(CharCode.D, KeyCode.KEY_D);
_registerLetterIfMissing(CharCode.E, KeyCode.KEY_E);
_registerLetterIfMissing(CharCode.F, KeyCode.KEY_F);
_registerLetterIfMissing(CharCode.G, KeyCode.KEY_G);
_registerLetterIfMissing(CharCode.H, KeyCode.KEY_H);
_registerLetterIfMissing(CharCode.I, KeyCode.KEY_I);
_registerLetterIfMissing(CharCode.J, KeyCode.KEY_J);
_registerLetterIfMissing(CharCode.K, KeyCode.KEY_K);
_registerLetterIfMissing(CharCode.L, KeyCode.KEY_L);
_registerLetterIfMissing(CharCode.M, KeyCode.KEY_M);
_registerLetterIfMissing(CharCode.N, KeyCode.KEY_N);
_registerLetterIfMissing(CharCode.O, KeyCode.KEY_O);
_registerLetterIfMissing(CharCode.P, KeyCode.KEY_P);
_registerLetterIfMissing(CharCode.Q, KeyCode.KEY_Q);
_registerLetterIfMissing(CharCode.R, KeyCode.KEY_R);
_registerLetterIfMissing(CharCode.S, KeyCode.KEY_S);
_registerLetterIfMissing(CharCode.T, KeyCode.KEY_T);
_registerLetterIfMissing(CharCode.U, KeyCode.KEY_U);
_registerLetterIfMissing(CharCode.V, KeyCode.KEY_V);
_registerLetterIfMissing(CharCode.W, KeyCode.KEY_W);
_registerLetterIfMissing(CharCode.X, KeyCode.KEY_X);
_registerLetterIfMissing(CharCode.Y, KeyCode.KEY_Y);
_registerLetterIfMissing(CharCode.Z, KeyCode.KEY_Z);
}
public dumpDebugInfo(): string {
......
......@@ -482,9 +482,25 @@ suite('keyboardMapper - WINDOWS ru', () => {
test('mapping', (done) => {
assertMapping(WRITE_FILE_IF_DIFFERENT, mapper, 'win_ru.txt', done);
});
test('issue ##24361: resolveKeybinding Ctrl+K Ctrl+K', () => {
_assertResolveKeybinding(
mapper,
KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_K),
[{
label: 'Ctrl+K Ctrl+K',
ariaLabel: 'Control+K Control+K',
electronAccelerator: null,
userSettingsLabel: 'ctrl+k ctrl+k',
isWYSIWYG: true,
isChord: true,
dispatchParts: ['ctrl+K', 'ctrl+K'],
}]
);
});
});
suite('misc', () => {
suite('keyboardMapper - misc', () => {
test('issue #23513: Toggle Sidebar Visibility and Go to Line display same key mapping in Arabic keyboard', () => {
const mapper = new WindowsKeyboardMapper(false, {
'KeyB': {
......@@ -507,11 +523,11 @@ suite('misc', () => {
mapper,
KeyMod.CtrlCmd | KeyCode.KEY_B,
[{
label: 'Ctrl+لا',
ariaLabel: 'Control+لا',
label: 'Ctrl+B',
ariaLabel: 'Control+B',
electronAccelerator: 'Ctrl+B',
userSettingsLabel: 'ctrl+b',
isWYSIWYG: false,
isWYSIWYG: true,
isChord: false,
dispatchParts: ['ctrl+B', null],
}]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册