Skip to content

Commit

Permalink
fixed exports
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Jan 4, 2023
1 parent 2061236 commit 33d6d41
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions tabby-core/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ export { VaultService, Vault, VaultSecret, VaultFileSecret, VAULT_SECRET_TYPE_FI
export { FileProvidersService } from '../services/fileProviders.service'
export { LocaleService, TranslateServiceWrapper as TranslateService } from '../services/locale.service'
export * from '../utils'
export { UTF8Splitter } from '../utfSplitter'
32 changes: 32 additions & 0 deletions tabby-core/src/utfSplitter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const partials = [
[0b110, 5, 0],
[0b1110, 4, 1],
[0b11110, 3, 2],
]

export class UTF8Splitter {
private internal = Buffer.alloc(0)

write (data: Buffer): Buffer {
this.internal = Buffer.concat([this.internal, data])

let keep = 0
for (const [pattern, shift, maxOffset] of partials) {
for (let offset = 0; offset < maxOffset + 1; offset++) {
if (this.internal[this.internal.length - offset - 1] >> shift === pattern) {
keep = Math.max(keep, offset + 1)
}
}
}

const result = this.internal.slice(0, this.internal.length - keep)
this.internal = this.internal.slice(this.internal.length - keep)
return result
}

flush (): Buffer {
const result = this.internal
this.internal = Buffer.alloc(0)
return result
}
}
3 changes: 1 addition & 2 deletions tabby-ssh/src/session/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { Observable, Subject } from 'rxjs'
import stripAnsi from 'strip-ansi'
import { ClientChannel } from 'ssh2'
import { Injector } from '@angular/core'
import { LogService } from 'tabby-core'
import { LogService, UTF8Splitter } 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 {
Expand Down

0 comments on commit 33d6d41

Please sign in to comment.