@@ -29,12 +29,6 @@ let sbtProcess: ChildProcess | undefined
2929/** The status bar where the show the status of sbt server */
3030let sbtStatusBar : vscode . StatusBarItem
3131
32- /** Interval in ms to check that sbt is alive */
33- const sbtCheckIntervalMs = 10 * 1000
34-
35- /** A command that we use to check that sbt is still alive. */
36- export const nopCommand = "nop"
37-
3832const sbtVersion = "1.2.3"
3933const sbtArtifact = `org.scala-sbt:sbt-launch:${ sbtVersion } `
4034const workspaceRoot = `${ vscode . workspace . rootPath } `
@@ -122,8 +116,8 @@ function connectToSbt(coursierPath: string): Thenable<rpc.MessageConnection> {
122116
123117 return offeringToRetry ( ( ) => {
124118 return withSbtInstance ( coursierPath ) . then ( connection => {
119+ connection . onClose ( ( ) => markSbtDownAndReconnect ( coursierPath ) )
125120 markSbtUp ( )
126- const interval = setInterval ( ( ) => checkSbt ( interval , connection , coursierPath ) , sbtCheckIntervalMs )
127121 return connection
128122 } )
129123 } , "Couldn't connect to sbt server (see log for details)" )
@@ -144,16 +138,6 @@ function markSbtDownAndReconnect(coursierPath: string) {
144138 connectToSbt ( coursierPath )
145139}
146140
147- /** Check that sbt is alive, try to reconnect if it is dead. */
148- function checkSbt ( interval : NodeJS . Timer , connection : rpc . MessageConnection , coursierPath : string ) {
149- sbtserver . tellSbt ( outputChannel , connection , nopCommand )
150- . then ( _ => markSbtUp ( ) ,
151- _ => {
152- clearInterval ( interval )
153- markSbtDownAndReconnect ( coursierPath )
154- } )
155- }
156-
157141export function deactivate ( ) {
158142 // If sbt was started by this extension, kill the process.
159143 // FIXME: This will be a problem for other clients of this server.
0 commit comments