Skip to content

Commit

Permalink
ssh: handle Unicode characters that are chopped up between chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Jan 4, 2023
1 parent e7cbb6a commit 2061236
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tabby-ssh/src/session/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ 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 {
shell?: ClientChannel
get serviceMessage$ (): Observable<string> { return this.serviceMessage }
private serviceMessage = new Subject<string>()
private ssh: SSHSession|null
private decoder = new UTF8Splitter()

constructor (
injector: Injector,
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 2061236

Please sign in to comment.