Skip to content

Commit bfcde1f

Browse files
Fix TreeSitterClient Not Being Set (#280)
1 parent 23fa1bf commit bfcde1f

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Sources/CodeEditSourceEditor/Controller/TextViewController.swift

+5
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ public class TextViewController: NSViewController {
254254
platformGuardedSystemCursor = false
255255
}
256256

257+
if let idx = highlightProviders.firstIndex(where: { $0 is TreeSitterClient }),
258+
let client = highlightProviders[idx] as? TreeSitterClient {
259+
self.treeSitterClient = client
260+
}
261+
257262
self.textView = TextView(
258263
string: string,
259264
font: font,

Tests/CodeEditSourceEditorTests/TextViewControllerTests.swift

+9
Original file line numberDiff line numberDiff line change
@@ -418,5 +418,14 @@ final class TextViewControllerTests: XCTestCase {
418418
XCTAssertEqual(controller.cursorPositions[1].line, 3)
419419
XCTAssertEqual(controller.cursorPositions[1].column, 1)
420420
}
421+
422+
// MARK: - TreeSitterClient
423+
424+
func test_treeSitterSetUp() {
425+
// Set up with a user-initiated `TreeSitterClient` should still use that client for things like tag
426+
// completion.
427+
let controller = Mock.textViewController(theme: Mock.theme())
428+
XCTAssertNotNil(controller.treeSitterClient)
429+
}
421430
}
422431
// swiftlint:enable all

0 commit comments

Comments
 (0)