Skip to content

Commit b62ae94

Browse files
committed
Add Test
1 parent 8dc31c3 commit b62ae94

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Tests/CodeEditTextViewTests/LayoutManager/TextLayoutManagerAttachmentsTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,14 @@ struct TextLayoutManagerAttachmentsTests {
108108
// Line "5" is from the trailing newline. That shows up as an empty line in the view.
109109
#expect(lines.map { $0.index } == [0, 4])
110110
}
111+
112+
@Test
113+
func addingAttachmentThatMeetsEndOfLineMergesNextLine() throws {
114+
let height = try #require(layoutManager.textLineForOffset(0)).height
115+
layoutManager.attachments.add(DemoTextAttachment(), for: NSRange(start: 0, end: 3))
116+
117+
// With bug: this the line for offset 3 is > 0 because it wasn't updated for the new attachment.
118+
#expect(layoutManager.textLineForOffset(0)?.height == height)
119+
#expect(layoutManager.textLineForOffset(3)?.height == 0)
120+
}
111121
}

0 commit comments

Comments
 (0)