Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pressing backspace from last newline causes uncaught error #297

Closed
KaiTheRedNinja opened this issue Oct 15, 2022 · 3 comments
Closed

Pressing backspace from last newline causes uncaught error #297

KaiTheRedNinja opened this issue Oct 15, 2022 · 3 comments
Assignees
Labels
bug Something isn't working Verified Verified bug
Milestone

Comments

@KaiTheRedNinja
Copy link
Contributor

Description

The current editor has a feature similar to Xcode where there is always one trailing line at the end of the file. However, if the user puts the cursor at said last line and pressing delete, then an uncaught error occurs.

This appears to be due to the layout manager. The error message produced does not crash the app but simply dumps a trace into the terminal.

2022-10-15 17:56:47.981415+0800 AuroraEditor[42145:6504027] [General] An uncaught exception was raised
2022-10-15 17:56:47.981589+0800 AuroraEditor[42145:6504027] [General] -[__NSCFString getLineStart:end:contentsEnd:forRange:]: Range {6982, 0} out of bounds; string length 6981
2022-10-15 17:56:48.017862+0800 AuroraEditor[42145:6504027] [General] (
	0   CoreFoundation                      0x00000001acb41148 __exceptionPreprocess + 240
	1   libobjc.A.dylib                     0x00000001ac88be04 objc_exception_throw + 60
	2   CoreFoundation                      0x00000001acc1316c -[__NSCFString characterAtIndex:].cold.1 + 0
	3   CoreFoundation                      0x00000001acb254bc CFStringGetLineBounds + 0
	4   Foundation                          0x00000001adb712d0 -[NSString lineRangeForRange:] + 68
	5   AuroraEditor                        0x0000000100d0b410 $sSo15NSLayoutManagerC12AuroraEditorE22enumerateFragmentRects17forLineContaining5usingySi_ySo6CGRectVctF + 420
	6   AuroraEditor                        0x0000000101240114 $s12AuroraEditor8CodeViewC17setSelectedRanges_8affinity14stillSelectingySaySo7NSValueCG_So19NSSelectionAffinityVSbtF + 1736
	7   AuroraEditor                        0x0000000101240d3c $s12AuroraEditor8CodeViewC17setSelectedRanges_8affinity14stillSelectingySaySo7NSValueCG_So19NSSelectionAffinityVSbtFTo + 108
	8   UIFoundation                        0x00000001b04bf834 -[NSLayoutManager textStorage:edited:range:changeInLength:invalidatedRange:] + 376
	9   AuroraEditor                        0x0000000100d0821c $s12AuroraEditor17CodeLayoutManagerC14processEditing3for6edited5range14changeInLength16invalidatedRangeySo13NSTextStorageC_So0pQ11EditActionsVSo8_NSRangeVSiAOtF + 540
	10  AuroraEditor                        0x0000000100d08a3c $s12AuroraEditor17CodeLayoutManagerC14processEditing3for6edited5range14changeInLength16invalidatedRangeySo13NSTextStorageC_So0pQ11EditActionsVSo8_NSRangeVSiAOtFTo + 140
	11  AuroraEditor                        0x0000000100fef378 $s12AuroraEditor11CodeStorageC14processEditingyyFySo15NSLayoutManagerCXEfU_ + 236
	12  AuroraEditor                        0x0000000100ff91b4 $s12AuroraEditor11CodeStorageC14processEditingyyFySo15NSLayoutManagerCXEfU_TA + 32
	13  libswiftCore.dylib                  0x00000001b9c44608 $sSTsE7forEachyyy7ElementQzKXEKF + 696
	14  AuroraEditor                        0x0000000100feece0 $s12AuroraEditor11CodeStorageC14processEditingyyF + 756
	15  AuroraEditor                        0x0000000100fef46c $s12AuroraEditor11CodeStorageC14processEditingyyFTo + 36
	16  UIFoundation                        0x00000001b04f23a0 -[NSTextStorage endEditing] + 116
	17  AuroraEditor                        0x0000000100fea850 $s12AuroraEditor11CodeStorageC17replaceCharacters2in4withySo8_NSRangeV_SStF + 1276
	18  AuroraEditor                        0x0000000100feaa48 $s12AuroraEditor11CodeStorageC17replaceCharacters2in4withySo8_NSRangeV_SStFTo + 100
	19  AppKit                              0x00000001af99ba08 -[NSTextView(NSPrivate) _userReplaceRange:withString:] + 260
	20  AppKit                              0x00000001af99b48c _NSDoUserReplaceForCharRange + 480
	21  AppKit                              0x00000001af9e6c6c -[NSTextView(NSKeyBindingCommands) deleteBackward:] + 776
	22  AppKit                              0x00000001af90814c -[NSTextView doCommandBySelector:] + 216
	23  AppKit                              0x00000001af908034 -[NSTextInputContext(NSInputContext_WithCompletion) doCommandBySelector:completionHandler:] + 264
	24  AppKit                              0x00000001af831f8c -[NSKeyBindingManager(NSKeyBindingManager_MultiClients) interpretEventAsCommand:forClient:] + 1988
	25  AppKit                              0x00000001af83adf0 __84-[NSTextInputContext _handleEvent:options:allowingSyntheticEvent:completionHandler:]_block_invoke_5 + 384
	26  AppKit                              0x00000001b0008b3c __84-[NSTextInputContext _handleEvent:options:allowingSyntheticEvent:completionHandler:]_block_invoke_3.1027 + 108
	27  AppKit                              0x00000001af83ac2c -[NSTextInputContext tryHandleEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] + 148
	28  AppKit                              0x00000001b0008a94 __84-[NSTextInputContext _handleEvent:options:allowingSyntheticEvent:completionHandler:]_block_invoke.1024 + 324
	29  HIToolbox                           0x00000001b5738308 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_5 + 96
	30  HIToolbox                           0x00000001b574976c ___ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec_block_invoke + 148
	31  AppKit                              0x00000001b0003674 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke.341 + 604
	32  AppKit                              0x00000001af834084 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke_2 + 108
	33  AppKit                              0x00000001af833fc8 -[NSTextInputContext tryHandleTSMEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] + 148
	34  AppKit                              0x00000001af833464 -[NSTextInputContext handleTSMEvent:completionHandler:] + 2080
	35  AppKit                              0x00000001af832bc8 _NSTSMEventHandler + 348
	36  HIToolbox                           0x00000001b56d66c8 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1084
	37  HIToolbox                           0x00000001b56d5b4c _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 356
	38  HIToolbox                           0x00000001b56d59dc SendEventToEventTargetWithOptions + 44
	39  HIToolbox                           0x00000001b57347bc SendTSMEvent_WithCompletionHandler + 496
	40  HIToolbox                           0x00000001b5734cd4 __SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler_block_invoke + 456
	41  HIToolbox                           0x00000001b5734ae0 __SendFilterTextEvent_WithCompletionHandler_block_invoke + 228
	42  HIToolbox                           0x00000001b5734814 SendTSMEvent_WithCompletionHandler + 584
	43  HIToolbox                           0x00000001b5734584 SendFilterTextEvent_WithCompletionHandler + 260
	44  HIToolbox                           0x00000001b57341ac SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler + 296
	45  HIToolbox                           0x00000001b5733f38 __utDeliverTSMEvent_WithCompletionHandler_block_invoke_2 + 320
	46  HIToolbox                           0x00000001b5733cbc __utDeliverTSMEvent_WithCompletionHandler_block_invoke + 284
	47  HIToolbox                           0x00000001b5733b40 TSMKeyEvent_WithCompletionHandler + 624
	48  HIToolbox                           0x00000001b57338c0 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_4 + 320
	49  HIToolbox                           0x00000001b57336d0 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_3 + 348
	50  HIToolbox                           0x00000001b57333d4 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_2 + 348
	51  HIToolbox                           0x00000001b57330d8 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke + 340
	52  HIToolbox                           0x00000001b5721380 TSMProcessRawKeyEventWithOptionsAndCompletionHandler + 3404
	53  AppKit                              0x00000001b0008940 __84-[NSTextInputContext _handleEvent:options:allowingSyntheticEvent:completionHandler:]_block_invoke_3.1020 + 148
	54  AppKit                              0x00000001b00085f4 __204-[NSTextInputContext tryTSMProcessRawKeyEvent_orSubstitution:dispatchCondition:setupForDispatch:furtherCondition:doubleSpaceSubstitutionCondition:doubleSpaceSubstitutionWork:dispatchTSMWork:continuation:]_block_invoke.971 + 192
	55  AppKit                              0x00000001af831654 -[NSTextInputContext tryTSMProcessRawKeyEvent_orSubstitution:dispatchCondition:setupForDispatch:furtherCondition:doubleSpaceSubstitutionCondition:doubleSpaceSubstitutionWork:dispatchTSMWork:continuation:] + 344
	56  AppKit                              0x00000001af830f44 -[NSTextInputContext _handleEvent:options:allowingSyntheticEvent:completionHandler:] + 1528
	57  AppKit                              0x00000001af83090c -[NSTextInputContext _handleEvent:allowingSyntheticEvent:] + 140
	58  AppKit                              0x00000001af830728 -[NSView interpretKeyEvents:] + 196
	59  AppKit                              0x00000001af830538 -[NSTextView keyDown:] + 704
	60  AppKit                              0x00000001af797e88 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 5908
	61  AppKit                              0x00000001af79650c -[NSWindow(NSEventRouting) sendEvent:] + 348
	62  AppKit                              0x00000001af7954b4 -[NSApplication(NSEvent) sendEvent:] + 2780
	63  AppKit                              0x00000001afa4f0f4 -[NSApplication _handleEvent:] + 76
	64  AppKit                              0x00000001af617008 -[NSApplication run] + 636
	65  AppKit                              0x00000001af5e86fc NSApplicationMain + 1132
	66  AuroraEditor                        0x0000000100de0fb0 main + 12
	67  dyld                                0x000000010357d08c start + 520
)

To Reproduce

  1. Open a file
  2. Go to the very bottom trailing line
  3. Press delete
  4. The error appears in terminal

Expected behavior

The error message does not appear and the last trailing line remains if the second-last line has any non-whitespace characters in it.

Version information

Aurora Editor: [e.g. 1.0]
Commit: [e.g. d06fb30]
MacOS: [e.g. 12.3.0]
Xcode: [e.g. 13.3]

Additional context

No response

@KaiTheRedNinja KaiTheRedNinja added bug Something isn't working unverified bug report what is not yet verified. labels Oct 15, 2022
@nanashili
Copy link
Member

out of bounds error

@KaiTheRedNinja
Copy link
Contributor Author

indeed, however I am not entirely sure where it is called from or how to fix it.

@0xWDG 0xWDG added Verified Verified bug and removed unverified bug report what is not yet verified. labels Oct 18, 2022
This was referenced Oct 18, 2022
@0xWDG
Copy link
Member

0xWDG commented Oct 29, 2022

#309

@0xWDG 0xWDG closed this as completed Oct 29, 2022
@0xWDG 0xWDG added this to the Version 1.0 milestone Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Verified Verified bug
Projects
Archived in project
Development

No branches or pull requests

3 participants