diff --git a/Sources/Runestone/Library/UITextInput+Helpers.swift b/Sources/Runestone/Library/UITextInput+Helpers.swift index db115d56c..60b911840 100644 --- a/Sources/Runestone/Library/UITextInput+Helpers.swift +++ b/Sources/Runestone/Library/UITextInput+Helpers.swift @@ -6,7 +6,7 @@ import UIKit extension UITextInput where Self: NSObject { var sbs_textSelectionDisplayInteraction: UITextSelectionDisplayInteraction? { let interactionAssistantKey = "int" + "ssAnoitcare".reversed() + "istant" - let selectionViewManagerKey = "les_".reversed() + "ection" + "reganaMweiV".reversed() + let selectionViewManagerKey: String = "les_".reversed() + "ection" + "reganaMweiV".reversed() guard responds(to: Selector(interactionAssistantKey)) else { return nil } diff --git a/Sources/Runestone/TextView/Navigation/TextLocation.swift b/Sources/Runestone/TextView/Navigation/TextLocation.swift index df587505c..f70a762a0 100644 --- a/Sources/Runestone/TextView/Navigation/TextLocation.swift +++ b/Sources/Runestone/TextView/Navigation/TextLocation.swift @@ -7,6 +7,12 @@ public struct TextLocation: Hashable, Equatable { /// Column in the line. public let column: Int + /// Initializes TextLocation from the given line and column + public init (lineNumber: Int, column: Int) { + self.lineNumber = lineNumber + self.column = column + } + init(_ linePosition: LinePosition) { self.lineNumber = linePosition.row self.column = linePosition.column diff --git a/Sources/Runestone/TextView/SyntaxHighlighting/Internal/TreeSitter/TreeSitterInternalLanguageMode.swift b/Sources/Runestone/TextView/SyntaxHighlighting/Internal/TreeSitter/TreeSitterInternalLanguageMode.swift index aa2e44677..d089d7682 100644 --- a/Sources/Runestone/TextView/SyntaxHighlighting/Internal/TreeSitter/TreeSitterInternalLanguageMode.swift +++ b/Sources/Runestone/TextView/SyntaxHighlighting/Internal/TreeSitter/TreeSitterInternalLanguageMode.swift @@ -16,6 +16,7 @@ final class TreeSitterInternalLanguageMode: InternalLanguageMode { private let lineManager: LineManager private let rootLanguageLayer: TreeSitterLanguageLayer private let operationQueue = OperationQueue() + private let parseLock = NSLock() init(language: TreeSitterInternalLanguage, languageProvider: TreeSitterLanguageProvider?, stringView: StringView, lineManager: LineManager) { self.stringView = stringView @@ -37,7 +38,9 @@ final class TreeSitterInternalLanguageMode: InternalLanguageMode { } func parse(_ text: NSString) { - rootLanguageLayer.parse(text) + parseLock.withLock { + rootLanguageLayer.parse(text) + } } func parse(_ text: NSString, completion: @escaping ((Bool) -> Void)) {