Skip to content

Commit fa1e1fa

Browse files
committed
Fixes microsoft#112614: Improve key code => scan code mappings for Chinese keyboard layout
1 parent 9a958ed commit fa1e1fa

File tree

5 files changed

+92
-70
lines changed

5 files changed

+92
-70
lines changed

src/vs/base/common/charCode.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,12 @@ export const enum CharCode {
423423
U_GREEK_OXIA = 0x1FFD, // U+1FFD GREEK OXIA
424424
U_GREEK_DASIA = 0x1FFE, // U+1FFE GREEK DASIA
425425

426+
U_IDEOGRAPHIC_FULL_STOP = 0x3002, // U+3002 IDEOGRAPHIC FULL STOP
427+
U_LEFT_CORNER_BRACKET = 0x300C, // U+300C LEFT CORNER BRACKET
428+
U_RIGHT_CORNER_BRACKET = 0x300D, // U+300D RIGHT CORNER BRACKET
429+
U_LEFT_BLACK_LENTICULAR_BRACKET = 0x3010, // U+3010 LEFT BLACK LENTICULAR BRACKET
430+
U_RIGHT_BLACK_LENTICULAR_BRACKET = 0x3011, // U+3011 RIGHT BLACK LENTICULAR BRACKET
431+
426432

427433
U_OVERLINE = 0x203E, // Unicode Character 'OVERLINE'
428434

@@ -431,5 +437,8 @@ export const enum CharCode {
431437
* Unicode Character 'ZERO WIDTH NO-BREAK SPACE' (U+FEFF)
432438
* http://www.fileformat.info/info/unicode/char/feff/index.htm
433439
*/
434-
UTF8_BOM = 65279
440+
UTF8_BOM = 65279,
441+
442+
U_FULLWIDTH_SEMICOLON = 0xFF1B, // U+FF1B FULLWIDTH SEMICOLON
443+
U_FULLWIDTH_COMMA = 0xFF0C, // U+FF0C FULLWIDTH COMMA
435444
}

src/vs/workbench/services/keybinding/common/macLinuxKeyboardMapper.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,21 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
10191019
return this._toResolvedKeybinding(parts);
10201020
}
10211021

1022+
private static _redirectCharCode(charCode: number): number {
1023+
switch (charCode) {
1024+
case CharCode.U_IDEOGRAPHIC_FULL_STOP: return CharCode.Period; // CJK 。 => .
1025+
case CharCode.U_LEFT_CORNER_BRACKET: return CharCode.OpenSquareBracket; // CJK 「 => [
1026+
case CharCode.U_RIGHT_CORNER_BRACKET: return CharCode.CloseSquareBracket; // CJK 」 => ]
1027+
case CharCode.U_LEFT_BLACK_LENTICULAR_BRACKET: return CharCode.OpenSquareBracket; // CJK 【 => [
1028+
case CharCode.U_RIGHT_BLACK_LENTICULAR_BRACKET: return CharCode.CloseSquareBracket; // CJK 】 => ]
1029+
case CharCode.U_FULLWIDTH_SEMICOLON: return CharCode.Semicolon; // CJK ; => ;
1030+
case CharCode.U_FULLWIDTH_COMMA: return CharCode.Comma; // CJK , => ,
1031+
}
1032+
return charCode;
1033+
}
1034+
10221035
private static _charCodeToKb(charCode: number): { keyCode: KeyCode; shiftKey: boolean } | null {
1036+
charCode = this._redirectCharCode(charCode);
10231037
if (charCode < CHAR_CODE_TO_KEY_CODE.length) {
10241038
return CHAR_CODE_TO_KEY_CODE[charCode];
10251039
}
@@ -1029,7 +1043,6 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
10291043
/**
10301044
* Attempt to map a combining character to a regular one that renders the same way.
10311045
*
1032-
* To the brave person following me: Good Luck!
10331046
* https://www.compart.com/en/unicode/bidiclass/NSM
10341047
*/
10351048
public static getCharCode(char: string): number {

src/vs/workbench/services/keybinding/test/electron-browser/keyboardMapperTestUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export function assertMapping(writeFileIfDifferent: boolean, mapper: IKeyboardMa
7070
const expected = buff.toString().replace(/\r\n/g, '\n');
7171
const actual = mapper.dumpDebugInfo().replace(/\r\n/g, '\n');
7272
if (actual !== expected && writeFileIfDifferent) {
73-
const destPath = filePath.replace(/vscode[\/\\]out[\/\\]vs/, 'vscode/src/vs');
73+
const destPath = filePath.replace(/[\/\\]out[\/\\]vs[\/\\]workbench/, '/src/vs/workbench');
7474
Promises.writeFile(destPath, actual);
7575
}
7676
assert.deepStrictEqual(actual, expected);

src/vs/workbench/services/keybinding/test/electron-browser/mac_zh_hant.txt

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -362,23 +362,23 @@ isUSStandard: false
362362
| Shift+Alt+Equal | + | Shift+Alt+= | | Shift+Alt+= | shift+alt+= | Shift+Alt+= | shift+alt+[Equal] | |
363363
| Ctrl+Shift+Alt+Equal | + | Ctrl+Shift+Alt+= | | Ctrl+Shift+Alt+= | ctrl+shift+alt+= | Ctrl+Shift+Alt+= | ctrl+shift+alt+[Equal] | |
364364
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
365-
| BracketLeft | 「 | | | 「 | [BracketLeft] | null | [BracketLeft] | NO |
366-
| Ctrl+BracketLeft | 「 | | | Ctrl+「 | ctrl+[BracketLeft] | null | ctrl+[BracketLeft] | NO |
367-
| Shift+BracketLeft | 『 | | | Shift+「 | shift+[BracketLeft] | null | shift+[BracketLeft] | NO |
368-
| Ctrl+Shift+BracketLeft | 『 | | | Ctrl+Shift+「 | ctrl+shift+[BracketLeft] | null | ctrl+shift+[BracketLeft] | NO |
369-
| Alt+BracketLeft | 「 | | | Alt+「 | alt+[BracketLeft] | null | alt+[BracketLeft] | NO |
370-
| Ctrl+Alt+BracketLeft | [ | [ | | Ctrl+Alt+「 | ctrl+alt+[BracketLeft] | null | ctrl+alt+[BracketLeft] | NO |
371-
| Shift+Alt+BracketLeft | 『 | | | Shift+Alt+「 | shift+alt+[BracketLeft] | null | shift+alt+[BracketLeft] | NO |
372-
| Ctrl+Shift+Alt+BracketLeft | { | Shift+[ | | Ctrl+Shift+Alt+「 | ctrl+shift+alt+[BracketLeft] | null | ctrl+shift+alt+[BracketLeft] | NO |
373-
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
374-
| BracketRight | 」 | | | 」 | [BracketRight] | null | [BracketRight] | NO |
375-
| Ctrl+BracketRight | 」 | | | Ctrl+」 | ctrl+[BracketRight] | null | ctrl+[BracketRight] | NO |
376-
| Shift+BracketRight | 』 | | | Shift+」 | shift+[BracketRight] | null | shift+[BracketRight] | NO |
377-
| Ctrl+Shift+BracketRight | 』 | | | Ctrl+Shift+」 | ctrl+shift+[BracketRight] | null | ctrl+shift+[BracketRight] | NO |
378-
| Alt+BracketRight | 」 | | | Alt+」 | alt+[BracketRight] | null | alt+[BracketRight] | NO |
379-
| Ctrl+Alt+BracketRight | ] | ] | | Ctrl+Alt+」 | ctrl+alt+[BracketRight] | null | ctrl+alt+[BracketRight] | NO |
380-
| Shift+Alt+BracketRight | 』 | | | Shift+Alt+」 | shift+alt+[BracketRight] | null | shift+alt+[BracketRight] | NO |
381-
| Ctrl+Shift+Alt+BracketRight | } | Shift+] | | Ctrl+Shift+Alt+」 | ctrl+shift+alt+[BracketRight] | null | ctrl+shift+alt+[BracketRight] | NO |
365+
| BracketLeft | 「 | [ | 1 | 「 | [ | [ | [BracketLeft] | NO |
366+
| Ctrl+BracketLeft | 「 | Ctrl+[ | | Ctrl+「 | ctrl+[ | Ctrl+[ | ctrl+[BracketLeft] | NO |
367+
| Shift+BracketLeft | 『 | Shift+[ | 1 | Shift+「 | shift+[ | Shift+[ | shift+[BracketLeft] | NO |
368+
| Ctrl+Shift+BracketLeft | 『 | Ctrl+Shift+[ | | Ctrl+Shift+「 | ctrl+shift+[ | Ctrl+Shift+[ | ctrl+shift+[BracketLeft] | NO |
369+
| Alt+BracketLeft | 「 | Alt+[ | | Alt+「 | alt+[ | Alt+[ | alt+[BracketLeft] | NO |
370+
| Ctrl+Alt+BracketLeft | [ | [ | 2 | Ctrl+Alt+「 | ctrl+alt+[BracketLeft] | Ctrl+Alt+[ | ctrl+alt+[BracketLeft] | NO |
371+
| Shift+Alt+BracketLeft | 『 | Shift+Alt+[ | | Shift+Alt+「 | shift+alt+[ | Shift+Alt+[ | shift+alt+[BracketLeft] | NO |
372+
| Ctrl+Shift+Alt+BracketLeft | { | Shift+[ | 2 | Ctrl+Shift+Alt+「 | ctrl+shift+alt+[BracketLeft] | Ctrl+Shift+Alt+[ | ctrl+shift+alt+[BracketLeft] | NO |
373+
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
374+
| BracketRight | 」 | ] | 1 | 」 | ] | ] | [BracketRight] | NO |
375+
| Ctrl+BracketRight | 」 | Ctrl+] | | Ctrl+」 | ctrl+] | Ctrl+] | ctrl+[BracketRight] | NO |
376+
| Shift+BracketRight | 』 | Shift+] | 1 | Shift+」 | shift+] | Shift+] | shift+[BracketRight] | NO |
377+
| Ctrl+Shift+BracketRight | 』 | Ctrl+Shift+] | | Ctrl+Shift+」 | ctrl+shift+] | Ctrl+Shift+] | ctrl+shift+[BracketRight] | NO |
378+
| Alt+BracketRight | 」 | Alt+] | | Alt+」 | alt+] | Alt+] | alt+[BracketRight] | NO |
379+
| Ctrl+Alt+BracketRight | ] | ] | 2 | Ctrl+Alt+」 | ctrl+alt+[BracketRight] | Ctrl+Alt+] | ctrl+alt+[BracketRight] | NO |
380+
| Shift+Alt+BracketRight | 』 | Shift+Alt+] | | Shift+Alt+」 | shift+alt+] | Shift+Alt+] | shift+alt+[BracketRight] | NO |
381+
| Ctrl+Shift+Alt+BracketRight | } | Shift+] | 2 | Ctrl+Shift+Alt+」 | ctrl+shift+alt+[BracketRight] | Ctrl+Shift+Alt+] | ctrl+shift+alt+[BracketRight] | NO |
382382
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
383383
| HW Code combination | Key | KeyCode combination | Pri | UI label | User settings | Electron accelerator | Dispatching string | WYSIWYG |
384384
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -431,20 +431,20 @@ isUSStandard: false
431431
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
432432
| Comma | ㄝ | | | ㄝ | [Comma] | null | [Comma] | NO |
433433
| Ctrl+Comma | ㄝ | | | Ctrl+ㄝ | ctrl+[Comma] | null | ctrl+[Comma] | NO |
434-
| Shift+Comma | , | | | Shift+ㄝ | shift+[Comma] | null | shift+[Comma] | NO |
435-
| Ctrl+Shift+Comma | , | | | Ctrl+Shift+ㄝ | ctrl+shift+[Comma] | null | ctrl+shift+[Comma] | NO |
434+
| Shift+Comma | , | , | 1 | Shift+ㄝ | shift+[Comma] | null | shift+[Comma] | NO |
435+
| Ctrl+Shift+Comma | , | Ctrl+, | | Ctrl+Shift+ㄝ | ctrl+shift+[Comma] | null | ctrl+shift+[Comma] | NO |
436436
| Alt+Comma | ㄝ | | | Alt+ㄝ | alt+[Comma] | null | alt+[Comma] | NO |
437-
| Ctrl+Alt+Comma | , | , | | Ctrl+Alt+ㄝ | ctrl+alt+[Comma] | null | ctrl+alt+[Comma] | NO |
438-
| Shift+Alt+Comma | , | | | Shift+Alt+ㄝ | shift+alt+[Comma] | null | shift+alt+[Comma] | NO |
437+
| Ctrl+Alt+Comma | , | , | 2 | Ctrl+Alt+ㄝ | ctrl+alt+[Comma] | null | ctrl+alt+[Comma] | NO |
438+
| Shift+Alt+Comma | , | Alt+, | | Shift+Alt+ㄝ | shift+alt+[Comma] | null | shift+alt+[Comma] | NO |
439439
| Ctrl+Shift+Alt+Comma | < | Shift+, | | Ctrl+Shift+Alt+ㄝ | ctrl+shift+alt+[Comma] | null | ctrl+shift+alt+[Comma] | NO |
440440
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
441441
| Period | ㄡ | | | ㄡ | [Period] | null | [Period] | NO |
442442
| Ctrl+Period | ㄡ | | | Ctrl+ㄡ | ctrl+[Period] | null | ctrl+[Period] | NO |
443-
| Shift+Period | 。 | | | Shift+ㄡ | shift+[Period] | null | shift+[Period] | NO |
444-
| Ctrl+Shift+Period | 。 | | | Ctrl+Shift+ㄡ | ctrl+shift+[Period] | null | ctrl+shift+[Period] | NO |
443+
| Shift+Period | 。 | . | 1 | Shift+ㄡ | shift+[Period] | null | shift+[Period] | NO |
444+
| Ctrl+Shift+Period | 。 | Ctrl+. | | Ctrl+Shift+ㄡ | ctrl+shift+[Period] | null | ctrl+shift+[Period] | NO |
445445
| Alt+Period | ㄡ | | | Alt+ㄡ | alt+[Period] | null | alt+[Period] | NO |
446-
| Ctrl+Alt+Period | . | . | | Ctrl+Alt+ㄡ | ctrl+alt+[Period] | null | ctrl+alt+[Period] | NO |
447-
| Shift+Alt+Period | 。 | | | Shift+Alt+ㄡ | shift+alt+[Period] | null | shift+alt+[Period] | NO |
446+
| Ctrl+Alt+Period | . | . | 2 | Ctrl+Alt+ㄡ | ctrl+alt+[Period] | null | ctrl+alt+[Period] | NO |
447+
| Shift+Alt+Period | 。 | Alt+. | | Shift+Alt+ㄡ | shift+alt+[Period] | null | shift+alt+[Period] | NO |
448448
| Ctrl+Shift+Alt+Period | > | Shift+. | | Ctrl+Shift+Alt+ㄡ | ctrl+shift+alt+[Period] | null | ctrl+shift+alt+[Period] | NO |
449449
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
450450
| Slash | ㄥ | | | ㄥ | [Slash] | null | [Slash] | NO |

0 commit comments

Comments
 (0)