mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-09 05:50:08 +00:00
perf: reduced pty bufferization window
This commit is contained in:
parent
50ab4fc37e
commit
2e6acd2fa1
@ -11,8 +11,11 @@ module.exports = function patchPTYModule (mod) {
|
||||
let lastFlush = 0
|
||||
let nextTimeout = 0
|
||||
|
||||
const maxWindow = 250
|
||||
const minWindow = 50
|
||||
// Minimum prebuffering window (ms) if the input is non-stop flowing
|
||||
const minWindow = 10
|
||||
|
||||
// Maximum buffering time (ms) until output must be flushed unconditionally
|
||||
const maxWindow = 100
|
||||
|
||||
function flush () {
|
||||
if (buffer) {
|
||||
@ -36,9 +39,11 @@ module.exports = function patchPTYModule (mod) {
|
||||
terminal.on('data', data => {
|
||||
buffer += data
|
||||
if (Date.now() - lastFlush > maxWindow) {
|
||||
// Taking too much time buffering, flush to keep things interactive
|
||||
flush()
|
||||
} else {
|
||||
if (Date.now() > nextTimeout - (minWindow / 10)) {
|
||||
if (Date.now() > nextTimeout - (maxWindow / 10)) {
|
||||
// Extend the window if it's expiring
|
||||
reschedule()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user