restores Helder in all its glory

This commit is contained in:
2026-09-28 11:34:49 +02:00
parent c2b38b853c
commit 1d29d0952d
280 changed files with 29205 additions and 7 deletions
@@ -0,0 +1,41 @@
import AppKit
import HelderCore
@testable import HelderUI
import Testing
@MainActor
@Suite struct EditorScrollOriginTests {
private static let text = (1...60).map { line in
line % 3 == 0
? "\(line): " + String(repeating: "a long line that runs well past ninety characters ", count: 3)
: "\(line): short line"
}.joined(separator: "\n")
private func open(wrap: Bool) -> (CodeEditorController, NSWindow) {
let controller = CodeEditorController()
let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 700, height: 900), styleMask: [.titled],
backing: .buffered, defer: false)
window.contentView = controller.scrollView
controller.apply(CodeEditorConfiguration(documentID: "notes.md", path: "notes.md", text: Self.text, revision: 1,
language: nil, isEditable: true, wrap: wrap, tabSize: 4, marksKey: "", makeMarks: { [:] },
opensDiffOnClick: false, knownSymbols: [], symbolsVersion: 0, flash: nil, focusRequest: 0,
selectAllRequest: 0, fontScale: 1, isShown: true))
return (controller, window)
}
@Test(arguments: [true, false])
func aNewDocumentStartsRightOfTheGutter(wrap: Bool) {
let (controller, window) = open(wrap: wrap)
let clip = controller.scrollView.contentView
#expect(clip.bounds.origin.x == -clip.contentInsets.left)
withExtendedLifetime(window) {}
}
@Test func wrappedTextFitsTheWidthRightOfTheGutter() {
let (controller, window) = open(wrap: true)
RunLoop.main.run(until: Date().addingTimeInterval(0.2))
window.displayIfNeeded()
let scrollView = controller.scrollView
#expect(controller.textView.frame.width == scrollView.contentSize.width - scrollView.contentView.contentInsets.left)
}
}