Skip to content

Commit 712cb58

Browse files
committed
Fix tests, remove warnings
1 parent 39f0749 commit 712cb58

3 files changed

Lines changed: 9 additions & 10 deletions

File tree

Sources/CodeEditTextView/Extensions/NSRange+/NSRange+InputEdit.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import SwiftTreeSitter
1010

1111
extension InputEdit {
1212
init?(range: NSRange, delta: Int, oldEndPoint: Point) {
13-
let startLocation = range.location
1413
let newEndLocation = NSMaxRange(range) + delta
1514

1615
if newEndLocation < 0 {

Sources/CodeEditTextView/Extensions/STTextView+/STTextView+VisibleRange.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ extension STTextView {
1717
}
1818
let container = self.textContainer
1919

20-
let origin = self.enclosingScrollView?.documentVisibleRect.origin ?? .zero
2120
let glyphRange = layoutManager.glyphRange(forBoundingRect: rect, in: container)
2221

2322
return layoutManager.characterRange(forGlyphRange: glyphRange, actualGlyphRange: nil)

Tests/CodeEditTextViewTests/STTextViewControllerTests.swift

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import XCTest
22
@testable import CodeEditTextView
33
import SwiftTreeSitter
4+
import AppKit
45

56
final class STTextViewControllerTests: XCTestCase {
67

@@ -38,25 +39,25 @@ final class STTextViewControllerTests: XCTestCase {
3839
func test_captureNames() throws {
3940
// test for "keyword"
4041
let captureName1 = "keyword"
41-
let color1 = controller.colorForCapture(captureName1)
42-
XCTAssertEqual(color1, .systemPink)
42+
let color1 = controller.attributesFor(CaptureName(rawValue: captureName1))[.foregroundColor] as? NSColor
43+
XCTAssertEqual(color1, NSColor.systemPink)
4344

4445
// test for "comment"
4546
let captureName2 = "comment"
46-
let color2 = controller.colorForCapture(captureName2)
47-
XCTAssertEqual(color2, .systemGreen)
47+
let color2 = controller.attributesFor(CaptureName(rawValue: captureName2))[.foregroundColor] as? NSColor
48+
XCTAssertEqual(color2, NSColor.systemGreen)
4849

4950
/* ... additional tests here ... */
5051

5152
// test for empty case
5253
let captureName3 = ""
53-
let color3 = controller.colorForCapture(captureName3)
54-
XCTAssertEqual(color3, .textColor)
54+
let color3 = controller.attributesFor(CaptureName(rawValue: captureName3))[.foregroundColor] as? NSColor
55+
XCTAssertEqual(color3, NSColor.textColor)
5556

5657
// test for random case
5758
let captureName4 = "abc123"
58-
let color4 = controller.colorForCapture(captureName4)
59-
XCTAssertEqual(color4, .textColor)
59+
let color4 = controller.attributesFor(CaptureName(rawValue: captureName4))[.foregroundColor] as? NSColor
60+
XCTAssertEqual(color4, NSColor.textColor)
6061
}
6162

6263
}

0 commit comments

Comments
 (0)