@@ -39,9 +39,8 @@ export interface Config extends BaseConfig {
3939
4040export function getSession ( c : Config ) : Session {
4141 if ( ! sessionInstance ) {
42- sessionInstance = new SSHSession ( ) ;
42+ sessionInstance = new SSHSession ( c , new Client ( ) ) ;
4343 }
44- sessionInstance . config = c ;
4544 return sessionInstance ;
4645}
4746export class SSHSession extends Session {
@@ -57,10 +56,10 @@ export class SSHSession extends Session {
5756 private _workDirectory : string ;
5857 private _workDirectoryParser : LineParser ;
5958
60- constructor ( c ?: Config ) {
59+ constructor ( c ?: Config , client ?: Client ) {
6160 super ( ) ;
6261 this . _config = c ;
63- this . _conn = new Client ( ) ;
62+ this . _conn = client ;
6463 this . _authMethods = [ "publickey" , "password" , "keyboard-interactive" ] ;
6564 this . _sessionReady = false ;
6665 this . _authHandler = new AuthHandler ( ) ;
@@ -96,12 +95,17 @@ export class SSHSession extends Session {
9695 readyTimeout : SAS_LAUNCH_TIMEOUT ,
9796 keepaliveInterval : KEEPALIVE_INTERVAL ,
9897 keepaliveCountMax : KEEPALIVE_UNANSWERED_THRESHOLD ,
98+
9999 debug : ( msg ) => {
100100 console . log ( msg ) ;
101101 } ,
102102 authHandler : this . handleSSHAuthentication ,
103103 } ;
104104
105+ if ( ! this . _conn ) {
106+ this . _conn = new Client ( ) ;
107+ }
108+
105109 this . _conn
106110 . on ( "ready" , ( ) => {
107111 this . _conn . shell ( this . onShell ) ;
@@ -179,6 +183,7 @@ export class SSHSession extends Session {
179183 this . clearAuthState ( ) ;
180184 this . _workDirectory = undefined ;
181185 this . _conn . end ( ) ;
186+ sessionInstance = undefined ;
182187 updateStatusBarItem ( false ) ;
183188 } ;
184189
@@ -227,7 +232,7 @@ export class SSHSession extends Session {
227232 if ( ! line ) {
228233 return ;
229234 }
230- const trimmedLine = line . trim ( ) ;
235+ const trimmedLine = line . trimEnd ( ) ;
231236 if ( trimmedLine . endsWith ( LineCodes . RunEndCode ) ) {
232237 // run completed
233238 this . getResult ( ) ;
0 commit comments