Skip to content

Commit cdc4f2b

Browse files
committed
Set cancelBuilds to 0 on close instead of open
1 parent 3300c77 commit cdc4f2b

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

Sources/SourceKitLSP/Swift/SwiftLanguageService.swift

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,7 @@ extension SwiftLanguageService {
326326
cancelInFlightPublishDiagnosticsTask(for: snapshot.uri)
327327
await diagnosticReportManager.removeItemsFromCache(with: snapshot.uri)
328328

329-
let keys = self.keys
330-
let path = snapshot.uri.pseudoPath
331-
332-
let closeReq = sourcekitd.dictionary([
333-
keys.request: requests.editorClose,
334-
keys.name: path,
335-
])
329+
let closeReq = closeDocumentSourcekitdRequest(uri: snapshot.uri)
336330
_ = try? await self.sourcekitd.send(closeReq, fileContents: nil)
337331

338332
let openReq = openDocumentSourcekitdRequest(snapshot: snapshot, compileCommand: compileCmd)
@@ -382,6 +376,13 @@ extension SwiftLanguageService {
382376
keys.enableDiagnostics: 0,
383377
keys.syntacticOnly: 1,
384378
keys.compilerArgs: compileCommand?.compilerArgs as [SKDRequestValue]?,
379+
])
380+
}
381+
382+
private func closeDocumentSourcekitdRequest(uri: DocumentURI) -> SKDRequestDictionary {
383+
return sourcekitd.dictionary([
384+
keys.request: requests.editorClose,
385+
keys.name: uri.pseudoPath,
385386
keys.cancelBuilds: 0,
386387
])
387388
}
@@ -421,17 +422,9 @@ extension SwiftLanguageService {
421422
inFlightPublishDiagnosticsTasks[note.textDocument.uri] = nil
422423
await diagnosticReportManager.removeItemsFromCache(with: note.textDocument.uri)
423424

424-
let keys = self.keys
425-
426425
self.documentManager.close(note)
427426

428-
let uri = note.textDocument.uri
429-
430-
let req = sourcekitd.dictionary([
431-
keys.request: self.requests.editorClose,
432-
keys.name: uri.pseudoPath,
433-
])
434-
427+
let req = closeDocumentSourcekitdRequest(uri: note.textDocument.uri)
435428
_ = try? await self.sourcekitd.send(req, fileContents: nil)
436429
}
437430

0 commit comments

Comments
 (0)