ssh: handle Unicode characters that are chopped up between chunks

This commit is contained in:
Eugene Pankov 2023-01-04 14:09:19 +01:00
parent e7cbb6a165
commit 206123615e
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4

View File

@ -6,6 +6,7 @@ import { LogService } from 'tabby-core'
import { BaseSession } from 'tabby-terminal'
import { SSHSession } from './ssh'
import { SSHProfile } from '../api'
import { UTF8Splitter } from '../../../app/lib/utfSplitter'
export class SSHShellSession extends BaseSession {
@ -13,6 +14,7 @@ export class SSHShellSession extends BaseSession {
get serviceMessage$ (): Observable<string> { return this.serviceMessage }
private serviceMessage = new Subject<string>()
private ssh: SSHSession|null
private decoder = new UTF8Splitter()
constructor (
injector: Injector,
@ -60,10 +62,14 @@ export class SSHShellSession extends BaseSession {
})
this.shell.on('data', data => {
this.emitOutput(data)
this.emitOutput(this.decoder.write(data))
})
this.shell.on('end', () => {
const remainder = this.decoder.flush()
if (remainder.length) {
this.emitOutput(remainder)
}
this.logger.info('Shell session ended')
if (this.open) {
this.destroy()