Skip to content

Commit d19234f

Browse files
committed
Replace .asyncAndWait with semaphore
1 parent 064854f commit d19234f

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

CodeEdit/Features/Documents/CodeFileDocument/CodeFileDocument.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,16 @@ final class CodeFileDocument: NSDocument, ObservableObject {
259259
// This blocks the presented item thread intentionally. If we don't wait, we'll receive more updates
260260
// that the file has changed and we'll end up dispatching multiple reads.
261261
// The presented item thread expects this operation to by synchronous anyways.
262-
DispatchQueue.main.asyncAndWait {
262+
263+
// https://github.com/CodeEditApp/CodeEdit/issues/2091
264+
// We can't use `.asyncAndWait` on Ventura as it seems the symbol is missing. Could be just for
265+
// x86 machines. We use a semaphore instead here.
266+
let semaphore = DispatchSemaphore(value: 0)
267+
DispatchQueue.main.async {
263268
try? self.read(from: fileURL, ofType: fileType)
269+
semaphore.signal()
264270
}
271+
semaphore.wait()
265272
}
266273
return
267274
}

0 commit comments

Comments
 (0)