Skip to content

Commit

Permalink
Add MainActor.assumeIsolated
Browse files Browse the repository at this point in the history
  • Loading branch information
1024jp committed Aug 25, 2024
1 parent e9bae2f commit 59d3d8c
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions CotEditor/Sources/DocumentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -414,18 +414,20 @@ final class DocumentViewController: NSSplitViewController, ThemeChanging, NSTool

guard textStorage.editedMask.contains(.editedCharacters) else { return }

// tell the parser that text was changed
self.document.syntaxParser.invalidateHighlight(in: textStorage.editedRange,
changeInLength: textStorage.changeInLength)

guard self.focusedTextView?.hasMarkedText() != true else { return }

self.document.counter.invalidateContent()
self.outlineParseDebouncer.schedule()

// -> Perform in the next run loop to give layoutManagers time to update their values.
DispatchQueue.main.async { [weak self] in
self?.document.syntaxParser.highlightIfNeeded()
MainActor.assumeIsolated {
// tell the parser that text was changed
self.document.syntaxParser.invalidateHighlight(in: textStorage.editedRange,
changeInLength: textStorage.changeInLength)

guard self.focusedTextView?.hasMarkedText() != true else { return }

self.document.counter.invalidateContent()
self.outlineParseDebouncer.schedule()

// -> Perform in the next run loop to give layoutManagers time to update their values.
DispatchQueue.main.async { [weak self] in
self?.document.syntaxParser.highlightIfNeeded()
}
}
}

Expand Down

0 comments on commit 59d3d8c

Please sign in to comment.