Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Commit 6455493

Browse files
sophiebitsfacebook-github-bot
authored andcommitted
Ctrl-K at end of line should delete newline
Summary: If you're at the end of a line and press Ctrl-K (on Mac OS), it should delete the newline (same as if you had just pressed forward-delete). Now it does (and stores the newline in the secondary clipboard, as Ctrl-K always does). Reviewed By: claudiopro Differential Revision: D13085302 fbshipit-source-id: b32cfcd41ad4ff482ff71621f98bd6524c415fc5
1 parent 010fce7 commit 6455493

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/component/handlers/edit/commands/SecondaryClipboard.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,19 @@ const SecondaryClipboard = {
3939
const blockEnd = content.getBlockForKey(anchorKey).getLength();
4040

4141
if (blockEnd === selection.getAnchorOffset()) {
42-
return editorState;
42+
targetRange = selection
43+
.set('focusKey', content.getKeyAfter(anchorKey))
44+
.set('focusOffset', 0);
45+
} else {
46+
targetRange = selection.set('focusOffset', blockEnd);
4347
}
44-
45-
targetRange = selection.set('focusOffset', blockEnd);
4648
} else {
4749
targetRange = selection;
4850
}
4951

5052
targetRange = nullthrows(targetRange);
53+
// TODO: This should actually append to the current state when doing
54+
// successive ^K commands without any other cursor movement
5155
clipboard = getContentStateFragment(content, targetRange);
5256

5357
const afterRemoval = DraftModifier.removeRange(

0 commit comments

Comments
 (0)