[SPIKE] Add delete to start of line for MacOS #636
+64
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
refs #445
Position.atStartOfLine
method that takes an existing position from which to find the start of it's lineline
unit for use ineditor.performDelete
line
unit when Meta+Backspace is pressedI had a quick stab at re-implementing the default MacOS Cmd+Backspace behaviour but it's highlighted a problem. macOS allows you to place the caret visually at the end of the line when it's actual position is at the start of the next line (either through clicking at the end of the line or using Cmd+Right). You can see a demonstration here:
When using both mobiledoc-kit's internal
position
and the browser-provideddocument.getSelection().getRangeAt(0).getBoundingClientRect()
the only position exposed to JS is the beginning of the next line. The reason this is a problem is because to faithfully replicate macOS' default behaviour the delete needs to happen from the visual caret position rather than the logical caret position.I disabled the delete key event handling in
event-manager.js
to demonstrate the native macOS behaviour where you can see the delete happening from the visual rather than logical position: