restores Helder in all its glory
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user