Просмотр исходного кода

fixed one-off sessions not auto closing

Eugene Pankov 4 лет назад
Родитель
Сommit
fe8dd891b4
1 измененных файлов с 5 добавлено и 4 удалено
  1. 5 4
      terminus-terminal/src/services/sessions.service.ts

+ 5 - 4
terminus-terminal/src/services/sessions.service.ts

@@ -147,6 +147,7 @@ export abstract class BaseSession {
 /** @hidden */
 export class Session extends BaseSession {
     private pty: PTYProxy|null = null
+    private ptyClosed = false
     private pauseAfterExit = false
     private guessedCWD: string|null = null
     private reportedCWD: string
@@ -246,6 +247,7 @@ export class Session extends BaseSession {
         })
 
         this.pty.subscribe('close', () => {
+            this.ptyClosed = true
             if (this.pauseAfterExit) {
                 this.emitOutput(Buffer.from('\r\nPress any key to close\r\n'))
             } else if (this.open) {
@@ -267,12 +269,11 @@ export class Session extends BaseSession {
     }
 
     write (data: Buffer): void {
+        if (this.ptyClosed) {
+            this.destroy()
+        }
         if (this.open) {
             this.pty?.write(data)
-            // TODO if (this.pty._writable) {
-            // } else {
-            //     this.destroy()
-            // }
         }
     }