From 65dc9fda6e774584db572eefca5b0ed9e566a52f Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 15 Aug 2017 09:25:23 +0100 Subject: [PATCH] Alter comments --- src/RichText.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/RichText.js b/src/RichText.js index a34f8b6b30..cbd3b9ae18 100644 --- a/src/RichText.js +++ b/src/RichText.js @@ -202,6 +202,9 @@ export function selectionStateToTextOffsets(selectionState: SelectionState, export function textOffsetsToSelectionState({start, end}: SelectionRange, contentBlocks: Array): SelectionState { let selectionState = SelectionState.createEmpty(); + // Subtract block lengths from `start` and `end` until they are less than the current + // block length (accounting for the NL at the end of each block). Set them to -1 to + // indicate that the corresponding selection state has been determined. for (const block of contentBlocks) { const blockLength = block.getLength(); // -1 indicating that the position start position has been found @@ -223,7 +226,7 @@ export function textOffsetsToSelectionState({start, end}: SelectionRange, focusKey: block.getKey(), focusOffset: end, }); - end = -1; // selection state for the start calculated + end = -1; // selection state for the end calculated } else { end -= blockLength + 1; // +1 to account for newline between blocks }