Skip to content

Commit

Permalink
Fixes #24107: Delete, Insert, Home, End, PgUp, PgDn, and arrow keys n…
Browse files Browse the repository at this point in the history
…o longer work editor in 1.11
  • Loading branch information
alexdima committed Apr 10, 2017
1 parent 9f34837 commit 1ac87a6
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1047,24 +1047,48 @@ export class MacLinuxKeyboardMapper implements IKeyboardMapper {
code = ScanCode.Enter;
}

const keyCode = keyboardEvent.keyCode;

if (
(code === ScanCode.Numpad1)
|| (code === ScanCode.Numpad2)
|| (code === ScanCode.Numpad3)
|| (code === ScanCode.Numpad4)
|| (code === ScanCode.Numpad5)
|| (code === ScanCode.Numpad6)
|| (code === ScanCode.Numpad7)
|| (code === ScanCode.Numpad8)
|| (code === ScanCode.Numpad9)
|| (code === ScanCode.Numpad0)
|| (code === ScanCode.NumpadDecimal)
(keyCode === KeyCode.LeftArrow)
|| (keyCode === KeyCode.UpArrow)
|| (keyCode === KeyCode.RightArrow)
|| (keyCode === KeyCode.DownArrow)
|| (keyCode === KeyCode.Delete)
|| (keyCode === KeyCode.Insert)
|| (keyCode === KeyCode.Home)
|| (keyCode === KeyCode.End)
|| (keyCode === KeyCode.PageDown)
|| (keyCode === KeyCode.PageUp)
) {
// "Dispatch" on keyCode for all numpad keys in order for NumLock to work correctly
if (keyboardEvent.keyCode >= 0) {
const immutableScanCode = IMMUTABLE_KEY_CODE_TO_CODE[keyboardEvent.keyCode];
if (immutableScanCode !== -1) {
code = immutableScanCode;
// "Dispatch" on keyCode for these key codes to workaround issues with remote desktoping software
// where the scan codes appear to be incorrect (see https://github.com/Microsoft/vscode/issues/24107)
const immutableScanCode = IMMUTABLE_KEY_CODE_TO_CODE[keyCode];
if (immutableScanCode !== -1) {
code = immutableScanCode;
}

} else {

if (
(code === ScanCode.Numpad1)
|| (code === ScanCode.Numpad2)
|| (code === ScanCode.Numpad3)
|| (code === ScanCode.Numpad4)
|| (code === ScanCode.Numpad5)
|| (code === ScanCode.Numpad6)
|| (code === ScanCode.Numpad7)
|| (code === ScanCode.Numpad8)
|| (code === ScanCode.Numpad9)
|| (code === ScanCode.Numpad0)
|| (code === ScanCode.NumpadDecimal)
) {
// "Dispatch" on keyCode for all numpad keys in order for NumLock to work correctly
if (keyCode >= 0) {
const immutableScanCode = IMMUTABLE_KEY_CODE_TO_CODE[keyCode];
if (immutableScanCode !== -1) {
code = immutableScanCode;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,66 @@ suite('keyboardMapper', () => {
assertNumpadKeyboardEvent(KeyCode.Delete, 'NumpadDecimal', 'Delete', 'Delete', 'delete', '[Delete]');
});

test('issue #24107: Delete, Insert, Home, End, PgUp, PgDn, and arrow keys no longer work editor in 1.11', () => {
let mapper = new MacLinuxKeyboardMapper(false, {}, OperatingSystem.Linux);

function _simpleHTMLLabel(pieces: string[]): IHTMLContentElement {
return simpleHTMLLabel(pieces, OperatingSystem.Linux);
}

function assertKeyboardEvent(keyCode: KeyCode, code: string, label: string, electronAccelerator: string, userSettingsLabel: string, dispatch: string): void {
assertResolveKeyboardEvent(
mapper,
{
ctrlKey: false,
shiftKey: false,
altKey: false,
metaKey: false,
keyCode: keyCode,
code: code
},
{
label: label,
ariaLabel: label,
HTMLLabel: [_simpleHTMLLabel([label])],
electronAccelerator: electronAccelerator,
userSettingsLabel: userSettingsLabel,
isWYSIWYG: true,
isChord: false,
hasCtrlModifier: false,
hasShiftModifier: false,
hasAltModifier: false,
hasMetaModifier: false,
dispatchParts: [dispatch, null],
}
);
}

// https://github.com/Microsoft/vscode/issues/24107#issuecomment-292318497
assertKeyboardEvent(KeyCode.UpArrow, 'Lang3', 'UpArrow', 'Up', 'up', '[ArrowUp]');
assertKeyboardEvent(KeyCode.DownArrow, 'NumpadEnter', 'DownArrow', 'Down', 'down', '[ArrowDown]');
assertKeyboardEvent(KeyCode.LeftArrow, 'Convert', 'LeftArrow', 'Left', 'left', '[ArrowLeft]');
assertKeyboardEvent(KeyCode.RightArrow, 'NonConvert', 'RightArrow', 'Right', 'right', '[ArrowRight]');
assertKeyboardEvent(KeyCode.Delete, 'PrintScreen', 'Delete', 'Delete', 'delete', '[Delete]');
assertKeyboardEvent(KeyCode.Insert, 'NumpadDivide', 'Insert', 'Insert', 'insert', '[Insert]');
assertKeyboardEvent(KeyCode.End, 'Unknown', 'End', 'End', 'end', '[End]');
assertKeyboardEvent(KeyCode.Home, 'IntlRo', 'Home', 'Home', 'home', '[Home]');
assertKeyboardEvent(KeyCode.PageDown, 'ControlRight', 'PageDown', 'PageDown', 'pagedown', '[PageDown]');
assertKeyboardEvent(KeyCode.PageUp, 'Lang4', 'PageUp', 'PageUp', 'pageup', '[PageUp]');

// https://github.com/Microsoft/vscode/issues/24107#issuecomment-292323924
assertKeyboardEvent(KeyCode.PageDown, 'ControlRight', 'PageDown', 'PageDown', 'pagedown', '[PageDown]');
assertKeyboardEvent(KeyCode.PageUp, 'Lang4', 'PageUp', 'PageUp', 'pageup', '[PageUp]');
assertKeyboardEvent(KeyCode.End, '', 'End', 'End', 'end', '[End]');
assertKeyboardEvent(KeyCode.Home, 'IntlRo', 'Home', 'Home', 'home', '[Home]');
assertKeyboardEvent(KeyCode.Delete, 'PrintScreen', 'Delete', 'Delete', 'delete', '[Delete]');
assertKeyboardEvent(KeyCode.Insert, 'NumpadDivide', 'Insert', 'Insert', 'insert', '[Insert]');
assertKeyboardEvent(KeyCode.RightArrow, 'NonConvert', 'RightArrow', 'Right', 'right', '[ArrowRight]');
assertKeyboardEvent(KeyCode.LeftArrow, 'Convert', 'LeftArrow', 'Left', 'left', '[ArrowLeft]');
assertKeyboardEvent(KeyCode.DownArrow, 'NumpadEnter', 'DownArrow', 'Down', 'down', '[ArrowDown]');
assertKeyboardEvent(KeyCode.UpArrow, 'Lang3', 'UpArrow', 'Up', 'up', '[ArrowUp]');
});

});

suite('keyboardMapper - LINUX ru', () => {
Expand Down

0 comments on commit 1ac87a6

Please sign in to comment.