mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-05 02:50:00 +00:00
handle buffers cut in the middle of a unicode char - fixes #3883, fixes #3882, fixes #3093, fixes #2043
This commit is contained in:
parent
ae7416792a
commit
1931b5ac7e
@ -1,4 +1,5 @@
|
|||||||
import * as nodePTY from '@terminus-term/node-pty'
|
import * as nodePTY from '@terminus-term/node-pty'
|
||||||
|
import { StringDecoder } from 'string_decoder'
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import { ipcMain } from 'electron'
|
import { ipcMain } from 'electron'
|
||||||
import { Application } from './app'
|
import { Application } from './app'
|
||||||
@ -9,6 +10,7 @@ class PTYDataQueue {
|
|||||||
private maxChunk = 1024
|
private maxChunk = 1024
|
||||||
private maxDelta = 1024 * 50
|
private maxDelta = 1024 * 50
|
||||||
private flowPaused = false
|
private flowPaused = false
|
||||||
|
private decoder = new StringDecoder('utf8')
|
||||||
|
|
||||||
constructor (private pty: nodePTY.IPty, private onData: (data: Buffer) => void) { }
|
constructor (private pty: nodePTY.IPty, private onData: (data: Buffer) => void) { }
|
||||||
|
|
||||||
@ -49,7 +51,7 @@ class PTYDataQueue {
|
|||||||
this.buffers.unshift(toSend.slice(this.maxChunk))
|
this.buffers.unshift(toSend.slice(this.maxChunk))
|
||||||
toSend = toSend.slice(0, this.maxChunk)
|
toSend = toSend.slice(0, this.maxChunk)
|
||||||
}
|
}
|
||||||
this.onData(toSend)
|
this.emitData(toSend)
|
||||||
this.delta += toSend.length
|
this.delta += toSend.length
|
||||||
|
|
||||||
if (this.buffers.length) {
|
if (this.buffers.length) {
|
||||||
@ -58,6 +60,10 @@ class PTYDataQueue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private emitData (data: Buffer) {
|
||||||
|
this.onData(Buffer.from(this.decoder.write(data)))
|
||||||
|
}
|
||||||
|
|
||||||
private pause () {
|
private pause () {
|
||||||
this.pty.pause()
|
this.pty.pause()
|
||||||
this.flowPaused = true
|
this.flowPaused = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user