Allow Shift-Delete to be used for Cut#1885
Open
logiclrd wants to merge 1 commit intobenweet:masterfrom
Open
Conversation
|
Wow I rarely enjoy reading a pull request 👏🏿 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR updates the handler in
cleditKeystroke.jsthat implements Delete functionality (to remove the selected text) to ignore events where the key event is Shift-Delete.First, some backstory: Two eternities ago, when user interfaces that didn't require you to type commands in one by one were a brand new thing, there were two different schools of thought that arose independently:
At the Xerox PARC, they created a user interface where Ctrl-X, Ctrl-C and Ctrl-V were mapped to cut, copy and paste, respectively. This was inherited by the Apple Lisa and subsequently the Macintosh, and became the standard for clipboard operations on Mac systems.
At IBM, a document was developed called the IBM Common User Access standard -- IBM CUA. Per IBM CUA, the cut, copy and paste operations are Shift-Delete, Ctrl-Insert and Shift-Insert, respectively. Applications by IBM for the IBM PC used this standard.
When Microsoft was mashing together the IBM world and the Macintosh world in a little DOS app called Windows, they saw both of these standards and implemented them both. As a result, from day 1, on Windows systems, you have always been able to take your pick between ^X ^C ^V and Shift-Del, Ctrl-Ins and Shift-Ins. This continues to this day. Modern Linux windowing systems often also set up these same mappings -- historically, ^X ^C ^V was for the Clipboard buffer and Shift-Del, Ctrl-Ins and Shift-Ins was for the Selection buffer, but common household distributions like Ubuntu do not preserve this distinction.
It is notable that to this day, the IBM CUA clipboard keys continue to be absent in Macintosh UI.
Now, to the issue at hand: Per issue #1279, in a much earlier revision of StackEdit, at least 6 years ago and probably a bit longer, clipboard manipulation keyboard mappings were delegated to the browser. Whatever the browser supported and turned into
'cut','copy'and'paste'events would behave this way within StackEdit. But, a change made back then added a new keystroke handler specific to Delete operations, and this handler reacts to any Backspace or Delete keystroke, irrespective of whether the shift key is down. As a result, it hijacks the browser's default behaviour for Shift-Delete.Ever since this change, Shift-Delete in StackEdit just deletes the selection, exactly as if Shift weren't pressed. People who use ^X ^C ^V for clipboard actions never even noticed this, but people whose muscle memory presses Shift-Delete for Cut have been very frustrated by this ever since. (I am one of them.)
(Note that Ctrl-Insert still copies and Shift-Insert still pastes, only Shift-Delete is inadvertently intercepted and remapped.)
This PR restores the functionality by adding a filter to the keystroke handler so that it responds to Delete but not to Shift-Delete.
Closes: #1279