krz/orgstar

A native macOS editor for org-mode files. editor org-mode swift

Commit 5d313b882d

5d313b882d074ec238c7165acee91a0ae5e4a41a

parent: 520c19a5a0

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-05 04:38 UTC

Bind list keys

Layout: unified · split

Tests/OrgEditorAppKitTests/KeyTests.swift +19
@@ -134,3 +134,22 @@ struct KeyTests {
134 } 134 }
135 } 135 }
136} 136}
137
138@MainActor
139struct ListKeyTests {
140 @Test func metaReturnInsertsAnItemInAListAndAHeadingElsewhere() {
141 let h = Harness("* a\n- x\n")
142 let event = { (flags: NSEvent.ModifierFlags) in
143 NSEvent.keyEvent(with: .keyDown, location: .zero, modifierFlags: flags, timestamp: 0, windowNumber: h.window.windowNumber,
144 context: nil, characters: "\r", charactersIgnoringModifiers: "\r", isARepeat: false, keyCode: 36)!
145 }
146 let meta = NSEvent.ModifierFlags(rawValue: NSEvent.ModifierFlags.option.rawValue | KeyEvents.leftOption)
147 h.caret(at: 7)
148 h.textView.keyDown(with: event(meta))
149 #expect(h.string == "* a\n- x\n- \n")
150 h.caret(at: 3)
151 h.textView.keyDown(with: event(meta))
152 #expect(h.string.hasPrefix("* a\n* \n"))
153 h.checkInSync()
154 }
155}