From 7f64fa9dddb8a2e88e06d3a00bc3eb6db1b009c4 Mon Sep 17 00:00:00 2001 From: Jason Lin Date: Tue, 6 Dec 2022 15:57:19 +1100 Subject: [PATCH 1/3] Send corresponding escape code for alt+space and ctrl+alt+space The previous behavior is that this combinations do nothing. --- src/common/input/Keyboard.test.ts | 6 ++++++ src/common/input/Keyboard.ts | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/common/input/Keyboard.test.ts b/src/common/input/Keyboard.test.ts index 68fbaac1..f2d0936b 100644 --- a/src/common/input/Keyboard.test.ts +++ b/src/common/input/Keyboard.test.ts @@ -125,6 +125,12 @@ describe('Keyboard', () => { it('should return \\x1ba for alt+a', () => { assert.equal(testEvaluateKeyboardEvent({ altKey: true, keyCode: 65 }, { isMac: false }).key, '\x1ba'); }); + it('should return \\x1b\\x20 for alt+space', () => { + assert.equal(testEvaluateKeyboardEvent({ altKey: true, keyCode: 32 }, { isMac: false }).key, '\x1b\x20'); + }); + it('should return \\x1b\\x00 for ctrl+alt+space', () => { + assert.equal(testEvaluateKeyboardEvent({ altKey: true, ctrlKey: true, keyCode: 32 }, { isMac: false }).key, '\x1b\x00'); + }); }); describe('On macOS platforms', () => { diff --git a/src/common/input/Keyboard.ts b/src/common/input/Keyboard.ts index 013a7711..225c914e 100644 --- a/src/common/input/Keyboard.ts +++ b/src/common/input/Keyboard.ts @@ -360,6 +360,8 @@ export function evaluateKeyboardEvent( keyString = keyString.toUpperCase(); } result.key = C0.ESC + keyString; + } else if (ev.keyCode === 32) { + result.key = C0.ESC + (ev.ctrlKey ? C0.NUL : ' '); } else if (ev.key === 'Dead' && ev.code.startsWith('Key')) { // Reference: https://github.com/xtermjs/xterm.js/issues/3725 // Alt will produce a "dead key" (initate composition) with some From dec3791f4c693132cf9252884359ea212fdd50cf Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 6 Dec 2022 14:04:10 -0800 Subject: [PATCH 2/3] Log a warning if task queues exceed deadline by 20ms Fixes #4292 --- src/common/TaskQueue.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/common/TaskQueue.ts b/src/common/TaskQueue.ts index 94c5c53b..4674ad5b 100644 --- a/src/common/TaskQueue.ts +++ b/src/common/TaskQueue.ts @@ -66,6 +66,8 @@ abstract class TaskQueue implements ITaskQueue { this._idleCallback = undefined; let taskDuration = 0; let longestTask = 0; + let lastDeadlineRemaining = deadline.timeRemaining(); + let deadlineRemaining = 0; while (this._i < this._tasks.length) { taskDuration = performance.now(); this._tasks[this._i++](); @@ -73,10 +75,17 @@ abstract class TaskQueue implements ITaskQueue { longestTask = Math.max(taskDuration, longestTask); // Guess the following task will take a similar time to the longest task in this batch, allow // additional room to try avoid exceeding the deadline - if (longestTask * 1.5 > deadline.timeRemaining()) { + deadlineRemaining = deadline.timeRemaining(); + if (longestTask * 1.5 > deadlineRemaining) { + // Warn when the time exceeding the deadline is over 20ms, if this happens in practice the + // task should be split into sub-tasks to ensure the UI remains responsive. + if (lastDeadlineRemaining - taskDuration < -5) { + console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(lastDeadlineRemaining - taskDuration))}ms`, { stacktrace: new Error().stack }); + } this._start(); return; } + lastDeadlineRemaining = deadlineRemaining; } this.clear(); } From 650cda31fd265a1798778787a426381c84098b2d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 6 Dec 2022 14:10:40 -0800 Subject: [PATCH 3/3] Tweak logging --- src/common/TaskQueue.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/TaskQueue.ts b/src/common/TaskQueue.ts index 4674ad5b..30068a5f 100644 --- a/src/common/TaskQueue.ts +++ b/src/common/TaskQueue.ts @@ -79,8 +79,8 @@ abstract class TaskQueue implements ITaskQueue { if (longestTask * 1.5 > deadlineRemaining) { // Warn when the time exceeding the deadline is over 20ms, if this happens in practice the // task should be split into sub-tasks to ensure the UI remains responsive. - if (lastDeadlineRemaining - taskDuration < -5) { - console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(lastDeadlineRemaining - taskDuration))}ms`, { stacktrace: new Error().stack }); + if (lastDeadlineRemaining - taskDuration < -20) { + console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(lastDeadlineRemaining - taskDuration))}ms`); } this._start(); return;