improvements on the ui

This commit is contained in:
2026-11-25 07:14:49 +01:00
parent 3afdb6d67f
commit b7c72b9e16
249 changed files with 19702 additions and 17358 deletions
+17 -6
View File
@@ -10,23 +10,34 @@ import Testing
text.components(separatedBy: "\n\n")
}
@Test("typing #lorem at the start of a line replaces it with lorem text in six blocks, caret at the end")
@Test("typing #lorem at the start of a line replaces it with lorem text in seven blocks, caret at the end")
func typedAtLineStart() throws {
let page = try TestPage()
page.type("#lorem")
let text = page.textView.string
#expect(!text.contains(LoremText.trigger))
#expect(parts(text).count == 6)
#expect(LoremText.wordCount(parts(text)[0]) == 16)
#expect(parts(text).count == 7)
#expect(parts(text)[0] == "=lorem")
#expect(LoremText.wordCount(parts(text)[1]) == 16)
#expect(page.textView.selectedRange() == NSRange(location: page.textView.length, length: 0))
}
@Test("lorem text goes through the normal change path: its six blocks get a created date")
@Test("lorem text goes through the normal change path: its seven blocks, =lorem included, get a created date")
func stampsDates() throws {
let page = try TestPage()
page.type("#lorem")
let now = dateLine(2026, 10, 17, 10, 0)
#expect(page.fileText.components(separatedBy: now).count - 1 == 6)
#expect(page.fileText.components(separatedBy: now).count - 1 == 7)
#expect(page.fileText.hasPrefix("\(now)\n=lorem\n\n\(now)\n"))
}
@Test("typed lorem text starts with the bookmark lorem, in the bookmark index with the date of its block")
func bookmark() throws {
let page = try TestPage()
page.type("#lorem")
#expect(page.textView.bookmarks.map(\.title) == ["lorem"])
#expect(page.textView.bookmarks.first?.range.location == 0)
#expect(page.page.bookmarkIndex.labels == ["lorem - 17 okt 10:00", "end"])
}
@Test("on a later line, with text after #lorem, the text stays after the lorem text")
@@ -38,7 +49,7 @@ import Testing
#expect(text.hasPrefix("first\n\n"))
#expect(text.hasSuffix("tail"))
#expect(!text.contains(LoremText.trigger))
#expect(parts(text).count == 7)
#expect(parts(text).count == 8)
#expect(page.textView.selectedRange() == NSRange(location: page.textView.length - 4, length: 0))
}