Skip to content

Commit 453910c

Browse files
committed
Merge branch 'main' into subclassing
2 parents 9e6e7f1 + bcd1679 commit 453910c

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

Sources/Runestone/Language/TreeSitter/TreeSitterLanguage.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,14 @@ private extension TreeSitterInternalLanguage {
9595

9696
private static func makeInternalQuery(from query: TreeSitterLanguage.Query?, with language: UnsafePointer<TSLanguage>) -> TreeSitterQuery? {
9797
if let string = query?.string {
98-
return try? TreeSitterQuery(source: string, language: language)
98+
do {
99+
return try TreeSitterQuery(source: string, language: language)
100+
} catch {
101+
#if DEBUG
102+
print("Invalid TreeSitterLanguage.Query. Error: \(error).")
103+
#endif
104+
return nil
105+
}
99106
} else {
100107
return nil
101108
}

Sources/Runestone/TextView/TextView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import UIKit
99
///
1010
/// The type does not subclass `UITextView` but its interface is kept close to `UITextView`.
1111
///
12-
/// When initially configuring the `TextView` with a theme, a language and the text to be shown, it is recommended the use the <doc:setState(_:addUndoAction:)> function.
13-
/// The function takes an instance of <doc:TextViewState> as input which can be created on a background queue to avoid blocking the main queue while doing the initial parse of a text.
14-
open class TextView: UIScrollView {
12+
/// When initially configuring the `TextView` with a theme, a language and the text to be shown, it is recommended to use the ``setState(_:addUndoAction:)`` function.
13+
/// The function takes an instance of ``TextViewState`` as input which can be created on a background queue to avoid blocking the main queue while doing the initial parse of a text.
14+
open final class TextView: UIScrollView {
1515
/// Delegate to receive callbacks for events triggered by the editor.
1616
public weak var editorDelegate: TextViewDelegate?
1717
/// Whether the text view is in a state where the contents can be edited.
@@ -531,7 +531,7 @@ open class TextView: UIScrollView {
531531
///
532532
/// The value only affects new line breaks inserted in the text view and changing this value does not change the line endings of the text in the text view. Defaults to Unix (LF).
533533
///
534-
/// The TextView will only update the line endings when text is modified through an external event, such as when the user typing on the keyboard, when the user is replacing selected text, and when pasting text into the text view. In all other cases, you should make sure that the text provided to the text view uses the desired line endings. This includes when calling <doc:TextView/setState(_:addUndoAction:)> and <doc:TextView/replaceText(in:)>.
534+
/// The TextView will only update the line endings when text is modified through an external event, such as when the user typing on the keyboard, when the user is replacing selected text, and when pasting text into the text view. In all other cases, you should make sure that the text provided to the text view uses the desired line endings. This includes when calling ``TextView/setState(_:addUndoAction:)`` and ``TextView/replaceText(in:)``.
535535
public var lineEndings: LineEnding {
536536
get {
537537
return textInputView.lineEndings

Sources/Runestone/TextView/TextViewDelegate.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public protocol TextViewDelegate: AnyObject {
3030
/// Tells the delegate when the text selection changes in the text view.
3131
/// - Parameter textView: The text view whose selection changed.
3232
///
33-
/// You can use <doc:TextView/selectedRange> of the text view to get the new selection.
33+
/// You can use ``TextView/selectedRange`` of the text view to get the new selection.
3434
func textViewDidChangeSelection(_ textView: TextView)
3535
/// Asks the delegate whether to replace the specified text in the text view.
3636
/// - Parameters:
@@ -79,12 +79,12 @@ public protocol TextViewDelegate: AnyObject {
7979
/// Tells the delegate that the text view looped to the last highlighted range.
8080
/// - Parameter textView: The text view that looped to the last highlighted range.
8181
///
82-
/// The text view will loop to the last highlighted range in response to calling <doc:TextView/selectPreviousHighlightedRange()> while the first highlighted range is selected.
82+
/// The text view will loop to the last highlighted range in response to calling ``TextView/selectPreviousHighlightedRange()`` while the first highlighted range is selected.
8383
func textViewDidLoopToLastHighlightedRange(_ textView: TextView)
8484
/// Tells the delegate that the text view looped to the first highlighted range.
8585
/// - Parameter textView: The text view that looped to the first highlighted range.
8686
///
87-
/// The text view will loop to the first highlighted range in response to calling <doc:TextView/selectNextHighlightedRange()> while the last highlighted range is selected.
87+
/// The text view will loop to the first highlighted range in response to calling ``TextView/selectNextHighlightedRange()`` while the last highlighted range is selected.
8888
func textViewDidLoopToFirstHighlightedRange(_ textView: TextView)
8989
/// Asks the delegate if the text in the highlighted range can be replaced.
9090
/// - Parameters:

Sources/Runestone/TextView/TextViewState.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22

33
/// Encapsulates the bare informations needed to do syntax highlighting in a text view.
44
///
5-
/// It is recommended to create an instance of `TextViewState` on a background queue and pass it to a <doc:TextView> instead of setting the text, theme and language on the text view separately.
5+
/// It is recommended to create an instance of `TextViewState` on a background queue and pass it to a ``TextView`` instead of setting the text, theme and language on the text view separately.
66
public final class TextViewState {
77
let stringView: StringView
88
let theme: Theme
@@ -21,7 +21,7 @@ public final class TextViewState {
2121
/// The value is `nil` if the line ending cannot be detected.
2222
public private(set) var detectedLineEndings: LineEnding?
2323

24-
/// Creates state that can be passed to an instance of <doc:TextView>.
24+
/// Creates state that can be passed to an instance of ``TextView``.
2525
/// - Parameters:
2626
/// - text: The text to display in the text view.
2727
/// - theme: The theme to use when syntax highlighting the text.
@@ -39,9 +39,9 @@ public final class TextViewState {
3939
prepare(with: text)
4040
}
4141

42-
/// Creates state that can be passed to an instance of <doc:TextView>.
42+
/// Creates state that can be passed to an instance of ``TextView``.
4343
///
44-
/// The created theme will use an instance of <doc:PlainTextLanguageMode>.
44+
/// The created theme will use an instance of ``PlainTextLanguageMode``.
4545
/// - Parameters:
4646
/// - text: The text to display in the text view.
4747
/// - theme: The theme to use when syntax highlighting the text.

0 commit comments

Comments
 (0)