Skip to content

Commit 4a924c4

Browse files
committed
Remove assertion that we can't register for change notifications twice in SwiftPMWorkspace
There’s no harm in registering for change notifications for the same file twice. Currently, this can happen if you open two files that have the same main file. `BuildSystemManager` checks that there are no more files referencing a main file before calling `unregisterForChangeNotifications`, so this is where the “complicated” logic lives that checks if sourcekit-lsp really isn’t interested in a file anymore. rdar://117603105
1 parent 2a51479 commit 4a924c4

File tree

2 files changed

+0
-4
lines changed

2 files changed

+0
-4
lines changed

Sources/SKSwiftPMWorkspace/SwiftPMWorkspace.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ extension SwiftPMWorkspace: SKCore.BuildSystem {
300300
}
301301

302302
public func registerForChangeNotifications(for uri: DocumentURI) async {
303-
assert(!self.watchedFiles.contains(uri), "Registered twice for change notifications of the same URI")
304303
self.watchedFiles.insert(uri)
305304
}
306305

Sources/SourceKitLSP/SourceKitServer.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,9 +1186,6 @@ extension SourceKitServer {
11861186
}
11871187

11881188
private func openDocument(_ note: DidOpenTextDocumentNotification, workspace: Workspace) async {
1189-
if documentManager.latestSnapshot(note.textDocument.uri) != nil {
1190-
logger.fault("Document '\(note.textDocument.uri.forLogging)' is already open!")
1191-
}
11921189
// Immediately open the document even if the build system isn't ready. This is important since
11931190
// we check that the document is open when we receive messages from the build system.
11941191
documentManager.open(note)

0 commit comments

Comments
 (0)