Skip to content

Commit f8a9f58

Browse files
author
Oil3
committed
DispatchQueue fix
1 parent 2b24786 commit f8a9f58

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>SchemeUserState</key>
6+
<dict>
7+
<key>CodeColors.xcscheme_^#shared#^_</key>
8+
<dict>
9+
<key>orderHint</key>
10+
<integer>0</integer>
11+
</dict>
12+
<key>QuickCodeColorLook.xcscheme_^#shared#^_</key>
13+
<dict>
14+
<key>orderHint</key>
15+
<integer>1</integer>
16+
</dict>
17+
</dict>
18+
</dict>
19+
</plist>

QuickCodeColorLook/LineReader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class LineReader {
77
var buffer: Data
88
var atEof: Bool = false
99

10-
private let accessQueue = DispatchQueue(label: "LineReaderAccessQueue")
10+
private let accessQueue = DispatchQueue(label: "LineReaderAccessQueue", qos: .userInitiated, attributes: .concurrent)
1111

1212
init?(url: URL, encoding: String.Encoding = .utf8, chunkSize: Int = 4096) {
1313
guard let fileHandle = try? FileHandle(forReadingFrom: url) else {

QuickCodeColorLook/SyntaxHighlighter.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ struct SyntaxHighlighter {
1818

1919
static func highlightLine(line: String, fileExtension: String) -> AttributedString {
2020
var lineAttributedString = AttributedString(line)
21-
applySyntaxHighlighting(to: &lineAttributedString, fileExtension: fileExtension)
22-
return lineAttributedString
21+
DispatchSerialQueue.global(qos: .userInteractive).async {
22+
23+
applySyntaxHighlighting(to: &lineAttributedString, fileExtension: fileExtension)
24+
}
25+
return lineAttributedString
26+
27+
2328
}
24-
2529
static func applySyntaxHighlighting(to attributedString: inout AttributedString, fileExtension: String) {
2630
let nsString = String(attributedString.characters) as NSString
2731
let wholeRange = NSRange(location: 0, length: nsString.length)

0 commit comments

Comments
 (0)