Skip to content

Commit

Permalink
Fix TreeSitterClient Not Being Set (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoolwinter authored Nov 21, 2024
1 parent 23fa1bf commit bfcde1f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ public class TextViewController: NSViewController {
platformGuardedSystemCursor = false
}

if let idx = highlightProviders.firstIndex(where: { $0 is TreeSitterClient }),
let client = highlightProviders[idx] as? TreeSitterClient {
self.treeSitterClient = client
}

self.textView = TextView(
string: string,
font: font,
Expand Down
9 changes: 9 additions & 0 deletions Tests/CodeEditSourceEditorTests/TextViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -418,5 +418,14 @@ final class TextViewControllerTests: XCTestCase {
XCTAssertEqual(controller.cursorPositions[1].line, 3)
XCTAssertEqual(controller.cursorPositions[1].column, 1)
}

// MARK: - TreeSitterClient

func test_treeSitterSetUp() {
// Set up with a user-initiated `TreeSitterClient` should still use that client for things like tag
// completion.
let controller = Mock.textViewController(theme: Mock.theme())
XCTAssertNotNil(controller.treeSitterClient)
}
}
// swiftlint:enable all

0 comments on commit bfcde1f

Please sign in to comment.