Skip to content

Commit

Permalink
fix: execute scans async in didChangeWorkspaceFolders and purgeCache (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiandoetsch authored Oct 23, 2024
1 parent 58542b7 commit 627b730
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion application/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ func Start(c *config.Config) {

handlers := handler.Map{}
srv = jrpc2.NewServer(handlers, &jrpc2.ServerOptions{
Logger: func(text string) {
c.Logger().Trace().Str("method", "jrpc-server").Msg(text)
},
RPCLog: RPCLogger{c},
AllowPush: true,
})
Expand Down Expand Up @@ -195,7 +198,7 @@ func workspaceDidChangeWorkspaceFoldersHandler(srv *jrpc2.Server) jrpc2.Handler
command.HandleFolders(bgCtx, srv, di.Notifier(), di.ScanPersister())
if config.CurrentConfig().IsAutoScanEnabled() {
for _, f := range changedFolders {
f.ScanFolder(ctx)
go f.ScanFolder(ctx)
}
}
return nil, nil
Expand Down
5 changes: 3 additions & 2 deletions domain/ide/command/clear_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,15 @@ func (cmd *clearCache) Execute(_ context.Context) (any, error) {

func (cmd *clearCache) purgeInMemoryCache(logger *zerolog.Logger, folderUri *lsp.DocumentURI) {
ws := workspace.Get()
for _, folder := range ws.Folders() {
trusted, _ := ws.GetFolderTrust()
for _, folder := range trusted {
if folderUri != nil && *folderUri != folder.Uri() {
continue
}
logger.Info().Msgf("deleting in-memory cache for folder %s", folder.Path())
folder.Clear()
if config.CurrentConfig().IsAutoScanEnabled() {
folder.ScanFolder(context.Background())
go folder.ScanFolder(context.Background())
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions domain/ide/command/folder_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ func sendFolderConfigsNotification(notifier noti.Notifier) {
folderConfig := c.FolderConfig(f.Path())
folderConfigs = append(folderConfigs, *folderConfig)
}

if folderConfigs == nil {
return
}
folderConfigsParam := types.FolderConfigsParam{FolderConfigs: folderConfigs}
notifier.Send(folderConfigsParam)
}
Expand Down

0 comments on commit 627b730

Please sign in to comment.