Skip to content

Commit 769aaf6

Browse files
committed
Some small enhancement accessing concurrent resources
1 parent f794220 commit 769aaf6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Diff for: ls/ls.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -154,18 +154,21 @@ func NewINOLanguageServer(stdin io.Reader, stdout io.Writer, config *Config) *IN
154154
}
155155

156156
func (ls *INOLanguageServer) InitializeReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.InitializeParams) (*lsp.InitializeResult, *jsonrpc.ResponseError) {
157+
ls.writeLock(logger, false)
158+
ls.sketchRoot = ideParams.RootURI.AsPath()
159+
ls.sketchName = ls.sketchRoot.Base()
160+
ls.buildSketchCpp = ls.buildSketchRoot.Join(ls.sketchName + ".ino.cpp")
161+
ls.writeUnlock(logger)
162+
157163
go func() {
158164
defer streams.CatchAndLogPanic()
159-
// Unlock goroutines waiting for clangd
165+
166+
// Unlock goroutines waiting for clangd at the end of the initialization.
160167
defer ls.clangdStarted.Broadcast()
161168

162169
logger := NewLSPFunctionLogger(color.HiCyanString, "INIT --- ")
163170
logger.Logf("initializing workbench: %s", ideParams.RootURI)
164171

165-
ls.sketchRoot = ideParams.RootURI.AsPath()
166-
ls.sketchName = ls.sketchRoot.Base()
167-
ls.buildSketchCpp = ls.buildSketchRoot.Join(ls.sketchName + ".ino.cpp")
168-
169172
if success, err := ls.generateBuildEnvironment(context.Background(), true, logger); err != nil {
170173
logger.Logf("error starting clang: %s", err)
171174
return

0 commit comments

Comments
 (0)