Skip to content

Commit 8fb6d89

Browse files
committed
Don't show error message for missing board without name (arduino/arduino-pro-ide#134)
1 parent e3a4767 commit 8fb6d89

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

handler/handler.go

+6-12
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ type InoHandler struct {
7272

7373
// ClangdProc contains the process input / output streams for clangd.
7474
type ClangdProc struct {
75-
Start func() (io.WriteCloser, io.ReadCloser, io.ReadCloser)
76-
Logs *StreamLogger
77-
initParams lsp.InitializeParams
75+
Start func() (io.WriteCloser, io.ReadCloser, io.ReadCloser)
76+
Logs *StreamLogger
7877
}
7978

8079
// FileData gathers information on a .ino source file.
@@ -174,8 +173,6 @@ func (handler *InoHandler) transformParamsToClangd(ctx context.Context, method s
174173
}
175174

176175
switch method {
177-
case "initialize":
178-
handler.clangdProc.initParams = *params.(*lsp.InitializeParams)
179176
case "textDocument/didOpen":
180177
p := params.(*lsp.DidOpenTextDocumentParams)
181178
uri = p.TextDocument.URI
@@ -353,17 +350,14 @@ func (handler *InoHandler) handleError(ctx context.Context, err error) error {
353350
submatch := exp.FindStringSubmatch(errorStr)
354351
message = submatch[1]
355352
} else if strings.Contains(errorStr, "platform not installed") || strings.Contains(errorStr, "no FQBN provided") {
356-
var board string
357353
if len(handler.config.SelectedBoard.Name) > 0 {
358-
board = handler.config.SelectedBoard.Name
359-
} else {
360-
board = handler.config.SelectedBoard.Fqbn
361-
}
362-
if len(board) > 0 {
354+
board := handler.config.SelectedBoard.Name
363355
message = "Editor support may be inaccurate because the core for the board `" + board + "` is not installed."
364356
message += " Use the Boards Manager to install it."
365357
} else {
366-
message = "Editor support may be inaccurate because the selected board is unkown."
358+
// This case happens most often when the app is started for the first time and no
359+
// board is selected yet. Don't bother the user with an error then.
360+
return err
367361
}
368362
} else if strings.Contains(errorStr, "No such file or directory") {
369363
exp, regexpErr := regexp.Compile("([\\w\\.\\-]+)\\.h: No such file or directory")

0 commit comments

Comments
 (0)