@@ -26,9 +26,6 @@ export let client: LanguageClient
2626/** The sbt process that may have been started by this extension */
2727let sbtProcess : ChildProcess | undefined
2828
29- /** The status bar where the show the status of sbt server */
30- let sbtStatusBar : vscode . StatusBarItem
31-
3229const sbtVersion = "1.2.3"
3330const sbtArtifact = `org.scala-sbt:sbt-launch:${ sbtVersion } `
3431export const workspaceRoot = `${ vscode . workspace . rootPath } `
@@ -81,7 +78,7 @@ export function activate(context: ExtensionContext) {
8178 } )
8279
8380 } else {
84- let configuredProject : Thenable < void > = Promise . resolve ( )
81+ let configuredProject : Thenable < { } > = Promise . resolve ( { } )
8582 if ( ! isConfiguredProject ( ) ) {
8683 configuredProject = vscode . window . showInformationMessage (
8784 "This looks like an unconfigured Scala project. Would you like to start the Dotty IDE?" ,
@@ -95,12 +92,15 @@ export function activate(context: ExtensionContext) {
9592 return Promise . reject ( )
9693 }
9794 } )
95+ . then ( _ => connectToSbt ( coursierPath ) )
96+ . then ( sbt => {
97+ return withProgress ( "Configuring Dotty IDE..." , configureIDE ( sbt ) )
98+ . then ( _ => sbtserver . tellSbt ( outputChannel , sbt , "exit" ) )
99+ } )
98100 }
99101
100102 if ( ! fs . existsSync ( disableDottyIDEFile ) ) {
101103 configuredProject
102- . then ( _ => connectToSbt ( coursierPath ) )
103- . then ( sbt => withProgress ( "Configuring Dotty IDE..." , configureIDE ( sbt ) ) )
104104 . then ( _ => runLanguageServer ( coursierPath , languageServerArtifactFile ) )
105105 }
106106 }
@@ -111,34 +111,14 @@ export function activate(context: ExtensionContext) {
111111 * connection is still alive. If it dies, restart sbt server.
112112 */
113113function connectToSbt ( coursierPath : string ) : Thenable < rpc . MessageConnection > {
114- if ( ! sbtStatusBar ) sbtStatusBar = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Right )
115- sbtStatusBar . text = "sbt server: connecting $(sync)"
116- sbtStatusBar . show ( )
117114
118115 return offeringToRetry ( ( ) => {
119116 return withSbtInstance ( coursierPath ) . then ( connection => {
120- connection . onClose ( ( ) => markSbtDownAndReconnect ( coursierPath ) )
121- markSbtUp ( )
122117 return connection
123118 } )
124119 } , "Couldn't connect to sbt server (see log for details)" )
125120}
126121
127- /** Mark sbt server as alive in the status bar */
128- function markSbtUp ( ) {
129- sbtStatusBar . text = "sbt server: up $(check)"
130- }
131-
132- /** Mark sbt server as dead and try to reconnect */
133- function markSbtDownAndReconnect ( coursierPath : string ) {
134- sbtStatusBar . text = "sbt server: down $(x)"
135- if ( sbtProcess ) {
136- sbtProcess . kill ( )
137- sbtProcess = undefined
138- }
139- connectToSbt ( coursierPath )
140- }
141-
142122export function deactivate ( ) {
143123 // If sbt was started by this extension, kill the process.
144124 // FIXME: This will be a problem for other clients of this server.
0 commit comments