Skip to content

Do proper clean-up of tmp directories #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions ls/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,5 @@ https://microsoft.github.io/language-server-protocol/
case <-c:
log.Println("INTERRUPTED")
}
inoHandler.CleanUp()
inoHandler.Close()
}