diff --git a/ls/ls.go b/ls/ls.go index bbe52a3..17e4f56 100644 --- a/ls/ls.go +++ b/ls/ls.go @@ -977,8 +977,8 @@ func (ls *INOLanguageServer) initializedNotifFromIDE(logger jsonrpc.FunctionLogg func (ls *INOLanguageServer) exitNotifFromIDE(logger jsonrpc.FunctionLogger) { ls.Clangd.conn.Exit() - logger.Logf("Arduino Language Server is shutting down.") - os.Exit(0) + logger.Logf("Arduino Language Server is exiting.") + ls.Close() } func (ls *INOLanguageServer) textDocumentDidOpenNotifFromIDE(logger jsonrpc.FunctionLogger, ideParam *lsp.DidOpenTextDocumentParams) { @@ -1381,18 +1381,6 @@ func (ls *INOLanguageServer) Close() { close(ls.closing) ls.closing = nil } - if ls.buildPath != nil { - ls.buildPath.RemoveAll() - } -} - -// CloseNotify returns a channel that is closed when the InoHandler is closed -func (ls *INOLanguageServer) CloseNotify() <-chan bool { - return ls.closing -} - -// CleanUp performs cleanup of the workspace and temp files create by the language server -func (ls *INOLanguageServer) CleanUp() { if ls.buildPath != nil { ls.buildPath.RemoveAll() ls.buildPath = nil @@ -1403,6 +1391,11 @@ func (ls *INOLanguageServer) CleanUp() { } } +// CloseNotify returns a channel that is closed when the InoHandler is closed +func (ls *INOLanguageServer) CloseNotify() <-chan bool { + return ls.closing +} + func (ls *INOLanguageServer) extractDataFolderFromArduinoCLI(logger jsonrpc.FunctionLogger) (*paths.Path, error) { var dataDir string if ls.config.CliPath == nil { diff --git a/main.go b/main.go index 1c3cd3c..3333672 100644 --- a/main.go +++ b/main.go @@ -155,6 +155,5 @@ https://microsoft.github.io/language-server-protocol/ case <-c: log.Println("INTERRUPTED") } - inoHandler.CleanUp() inoHandler.Close() }