Skip to content

Commit 537cf74

Browse files
committed
Move Struct, Update Tests
1 parent ca32b4c commit 537cf74

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// MarkedRanges.swift
3+
// CodeEditTextView
4+
//
5+
// Created by Khan Winter on 4/17/25.
6+
//
7+
8+
import AppKit
9+
10+
/// Struct for passing attribute and range information easily down into line fragments, typesetters w/o
11+
/// requiring a reference to the marked text manager.
12+
public struct MarkedRanges {
13+
let ranges: [NSRange]
14+
let attributes: [NSAttributedString.Key: Any]
15+
}

Sources/CodeEditTextView/MarkedTextManager/MarkedTextManager.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77

88
import AppKit
99

10-
/// Struct for passing attribute and range information easily down into line fragments, typesetters w/o
11-
/// requiring a reference to the marked text manager.
12-
public struct MarkedRanges {
13-
let ranges: [NSRange]
14-
let attributes: [NSAttributedString.Key: Any]
15-
}
16-
1710
/// Manages marked ranges. Not a public API.
1811
class MarkedTextManager {
1912
/// All marked ranges being tracked.

Tests/CodeEditTextViewTests/OverridingLayoutManagerRenderingTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct OverridingLayoutManagerRenderingTests {
6868
textLine.lineFragments.forEach { fragmentPosition in
6969
let idealHeight: CGFloat = 2.0
7070
textLine.lineFragments.update(
71-
atIndex: fragmentPosition.index,
71+
atOffset: fragmentPosition.index,
7272
delta: 0,
7373
deltaHeight: -(fragmentPosition.height - idealHeight)
7474
)
@@ -86,6 +86,7 @@ struct OverridingLayoutManagerRenderingTests {
8686
// Edit some text
8787

8888
textStorage.replaceCharacters(in: NSRange(location: 0, length: 0), with: "0\n1\r\n2\r")
89+
layoutManager.layoutLines(in: NSRect(x: 0, y: 0, width: 1000, height: 1000))
8990

9091
#expect(layoutManager.lineCount == 7)
9192
#expect(layoutManager.lineStorage.height == 14.0)

Tests/CodeEditTextViewTests/TypesetterTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class TypesetterTests: XCTestCase {
1111
let typesetter = Typesetter()
1212
typesetter.typeset(
1313
NSAttributedString(string: "testline\n"),
14+
documentRange: NSRange(location: 0, length: 9),
1415
displayData: unlimitedLineWidthDisplayData,
1516
breakStrategy: .word,
1617
markedRanges: nil
@@ -20,6 +21,7 @@ class TypesetterTests: XCTestCase {
2021

2122
typesetter.typeset(
2223
NSAttributedString(string: "testline\n"),
24+
documentRange: NSRange(location: 0, length: 9),
2325
displayData: unlimitedLineWidthDisplayData,
2426
breakStrategy: .character,
2527
markedRanges: nil
@@ -32,6 +34,7 @@ class TypesetterTests: XCTestCase {
3234
let typesetter = Typesetter()
3335
typesetter.typeset(
3436
NSAttributedString(string: "testline\r"),
37+
documentRange: NSRange(location: 0, length: 9),
3538
displayData: unlimitedLineWidthDisplayData,
3639
breakStrategy: .word,
3740
markedRanges: nil
@@ -41,6 +44,7 @@ class TypesetterTests: XCTestCase {
4144

4245
typesetter.typeset(
4346
NSAttributedString(string: "testline\r"),
47+
documentRange: NSRange(location: 0, length: 9),
4448
displayData: unlimitedLineWidthDisplayData,
4549
breakStrategy: .character,
4650
markedRanges: nil
@@ -53,6 +57,7 @@ class TypesetterTests: XCTestCase {
5357
let typesetter = Typesetter()
5458
typesetter.typeset(
5559
NSAttributedString(string: "testline\r\n"),
60+
documentRange: NSRange(location: 0, length: 10),
5661
displayData: unlimitedLineWidthDisplayData,
5762
breakStrategy: .word,
5863
markedRanges: nil
@@ -62,6 +67,7 @@ class TypesetterTests: XCTestCase {
6267

6368
typesetter.typeset(
6469
NSAttributedString(string: "testline\r\n"),
70+
documentRange: NSRange(location: 0, length: 10),
6571
displayData: unlimitedLineWidthDisplayData,
6672
breakStrategy: .character,
6773
markedRanges: nil

0 commit comments

Comments
 (0)