Skip to content

Commit 515e20b

Browse files
authored
Merge pull request #4 from hegrec/fix/callbackfs-pnp-panic
Fix panic from yarn-pnp initialization
2 parents 446cca0 + 66f802d commit 515e20b

4 files changed

Lines changed: 8 additions & 3 deletions

File tree

internal/api/server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ func (s *StdioServer) Run(ctx context.Context) error {
8585
projectSession := project.NewSession(&project.SessionInit{
8686
BackgroundCtx: ctx,
8787
Logger: nil, // TODO: Add logging support
88-
FS: fs,
88+
FS: fs,
89+
PnpApi: pnpApi,
8990
Options: &project.SessionOptions{
9091
CurrentDirectory: s.options.Cwd,
9192
DefaultLibraryPath: s.options.DefaultLibraryPath,

internal/lsp/server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,8 @@ func (s *Server) handleInitialized(ctx context.Context, params *lsproto.Initiali
11401140
PushDiagnosticsEnabled: !disablePushDiagnostics,
11411141
Locale: s.locale,
11421142
},
1143-
FS: fs,
1143+
FS: fs,
1144+
PnpApi: pnpApi,
11441145
Logger: s.logger,
11451146
Client: s,
11461147
NpmExecutor: s,

internal/project/session.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ type SessionInit struct {
6969
Logger logging.Logger
7070
NpmExecutor ata.NpmExecutor
7171
ParseCache *ParseCache
72+
PnpApi *pnp.PnpApi
7273
}
7374

7475
// Session manages the state of an LSP session. It receives textDocument
@@ -211,6 +212,7 @@ func NewSession(init *SessionInit) *Session {
211212
},
212213
),
213214
toPath,
215+
init.PnpApi,
214216
),
215217
initialUserPreferences: lsutil.NewDefaultUserPreferences(),
216218
workspaceUserPreferences: lsutil.NewDefaultUserPreferences(),

internal/project/snapshot.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ func NewSnapshot(
6363
autoImports *autoimport.Registry,
6464
autoImportsWatch *WatchedFiles[map[tspath.Path]string],
6565
toPath func(fileName string) tspath.Path,
66+
pnpApi *pnp.PnpApi,
6667
) *Snapshot {
67-
pnpApi := pnp.InitPnpApi(fs.fs, sessionOptions.CurrentDirectory)
6868
if pnpApi != nil {
6969
fs.fs = pnpvfs.From(fs.fs)
7070
}
@@ -464,6 +464,7 @@ func (s *Snapshot) Clone(ctx context.Context, change SnapshotChange, overlays ma
464464
autoImports,
465465
autoImportsWatch,
466466
s.toPath,
467+
s.pnpApi,
467468
)
468469
newSnapshot.parentId = s.id
469470
newSnapshot.ProjectCollection = projectCollection

0 commit comments

Comments
 (0)