Commit 5d313b882d
Verified · cmc
Layout: unified · split
Tests/OrgEditorAppKitTests/KeyTests.swift +19
| @@ -134,3 +134,22 @@ struct KeyTests { | ||
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | ||
| 138 | @MainActor | |
| 139 | struct 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 | } | |