Skip to content

Commit 9bc65c3

Browse files
committed
Merge branch 'master' into buffer_optimizations
2 parents a562f33 + fe30cd6 commit 9bc65c3

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/common/TaskQueue.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ abstract class TaskQueue implements ITaskQueue {
7171
this._idleCallback = undefined;
7272
let taskDuration = 0;
7373
let longestTask = 0;
74+
let lastDeadlineRemaining = deadline.timeRemaining();
75+
let deadlineRemaining = 0;
7476
while (this._i < this._tasks.length) {
7577
taskDuration = Date.now();
7678
if (!this._tasks[this._i]()) {
@@ -83,10 +85,17 @@ abstract class TaskQueue implements ITaskQueue {
8385
longestTask = Math.max(taskDuration, longestTask);
8486
// Guess the following task will take a similar time to the longest task in this batch, allow
8587
// additional room to try avoid exceeding the deadline
86-
if (longestTask * 1.5 > deadline.timeRemaining()) {
88+
deadlineRemaining = deadline.timeRemaining();
89+
if (longestTask * 1.5 > deadlineRemaining) {
90+
// Warn when the time exceeding the deadline is over 20ms, if this happens in practice the
91+
// task should be split into sub-tasks to ensure the UI remains responsive.
92+
if (lastDeadlineRemaining - taskDuration < -20) {
93+
console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(lastDeadlineRemaining - taskDuration))}ms`);
94+
}
8795
this._start();
8896
return;
8997
}
98+
lastDeadlineRemaining = deadlineRemaining;
9099
}
91100
this.clear();
92101
}

src/common/input/Keyboard.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ describe('Keyboard', () => {
125125
it('should return \\x1ba for alt+a', () => {
126126
assert.equal(testEvaluateKeyboardEvent({ altKey: true, keyCode: 65 }, { isMac: false }).key, '\x1ba');
127127
});
128+
it('should return \\x1b\\x20 for alt+space', () => {
129+
assert.equal(testEvaluateKeyboardEvent({ altKey: true, keyCode: 32 }, { isMac: false }).key, '\x1b\x20');
130+
});
131+
it('should return \\x1b\\x00 for ctrl+alt+space', () => {
132+
assert.equal(testEvaluateKeyboardEvent({ altKey: true, ctrlKey: true, keyCode: 32 }, { isMac: false }).key, '\x1b\x00');
133+
});
128134
});
129135

130136
describe('On macOS platforms', () => {

src/common/input/Keyboard.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ export function evaluateKeyboardEvent(
360360
keyString = keyString.toUpperCase();
361361
}
362362
result.key = C0.ESC + keyString;
363+
} else if (ev.keyCode === 32) {
364+
result.key = C0.ESC + (ev.ctrlKey ? C0.NUL : ' ');
363365
} else if (ev.key === 'Dead' && ev.code.startsWith('Key')) {
364366
// Reference: https://github.com/xtermjs/xterm.js/issues/3725
365367
// Alt will produce a "dead key" (initate composition) with some

0 commit comments

Comments
 (0)