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

Commit

Permalink
Revisit comment for todo of T65805998, validate there's nothing to wo…
Browse files Browse the repository at this point in the history
…rry about

Summary:
Double-checked the `getRangeAt` here. Turns out we have nothing to worry about, this won't throw.

Updated the comment to reflect so. Not deleting it in case someone in the future wonders about this.

Reviewed By: claudiopro

Differential Revision: D21604262

fbshipit-source-id: 826169bbf060312b8feb4a5e6e1ebcdd5603f7ef
  • Loading branch information
mrkev authored and facebook-github-bot committed May 19, 2020
1 parent c75f1e4 commit 268ece3
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ function keyCommandBackspaceToStartOfLine(
}
const {ownerDocument} = e.currentTarget;
const domSelection: SelectionObject = ownerDocument.defaultView.getSelection();
// TODO(T65805998): Noticed this while flowifiying: this could throw if nothing is
// selected. Not doing it now to keep my flowification diff from altering
// behaviour, but we should be safe and handle that case eventually.
// getRangeAt can technically throw if there's no selection, but we know
// there is one here because text editor has focus (the cursor is a
// selection of length 0). Therefore, we don't need to wrap this in a
// try-catch block.
let range = domSelection.getRangeAt(0);
range = expandRangeToStartOfLine(range);

Expand Down

0 comments on commit 268ece3

Please sign in to comment.