mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Merge branch 'master' into buffer_optimizations
This commit is contained in:
+10
-1
@@ -71,6 +71,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 = Date.now();
|
||||
if (!this._tasks[this._i]()) {
|
||||
@@ -83,10 +85,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 < -20) {
|
||||
console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(lastDeadlineRemaining - taskDuration))}ms`);
|
||||
}
|
||||
this._start();
|
||||
return;
|
||||
}
|
||||
lastDeadlineRemaining = deadlineRemaining;
|
||||
}
|
||||
this.clear();
|
||||
}
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user