Skip to content

Commit a79893a

Browse files
authored
Merge pull request #828 from ahoppen/ahoppen/unbalanced-unregister-notifications
Don’t crash when unregistering for change notifications of a file that isn’t watched
2 parents 02d3503 + c3d4579 commit a79893a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Sources/SKCore/BuildSystemManager.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,10 @@ extension BuildSystemManager: BuildSystem {
299299

300300
public func unregisterForChangeNotifications(for uri: DocumentURI) {
301301
queue.async {
302-
let mainFile = self.watchedFiles[uri]!.mainFile
302+
guard let mainFile = self.watchedFiles[uri]?.mainFile else {
303+
log("Unbalanced calls for registerForChangeNotifications and unregisterForChangeNotifications", level: .warning)
304+
return
305+
}
303306
self.watchedFiles[uri] = nil
304307
self.checkUnreferencedMainFile(mainFile)
305308
}

0 commit comments

Comments
 (0)