From a563e52a1897401d846747f6eb06f29ff1c3ca0f Mon Sep 17 00:00:00 2001 From: advu Date: Fri, 8 Nov 2024 12:18:01 +0200 Subject: [PATCH] fix bug --- client/components/GecView/index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/client/components/GecView/index.js b/client/components/GecView/index.js index 9e61ac97..e3343924 100644 --- a/client/components/GecView/index.js +++ b/client/components/GecView/index.js @@ -17,7 +17,6 @@ const Word = ({ word, isError, edit, index, onEditChange, errorAction, errorFeed return isError && edit.o_start === edit.o_end && edit.o_str === "" ? ( setHovered(true)} @@ -55,7 +54,6 @@ const Word = ({ word, isError, edit, index, onEditChange, errorAction, errorFeed ) : isError ? ( setHovered(true)} @@ -94,7 +92,7 @@ const Word = ({ word, isError, edit, index, onEditChange, errorAction, errorFeed )} ) : ( - + {word}{' '} ) @@ -158,6 +156,14 @@ const GrammarCheck = () => { const words = text.split(' ') const sentenceEdits = edits[index] || [] const modifiedSentence = [] + + // Loop through the sentence edits to adjust the words array with placeholders + sentenceEdits.forEach(edit => { + if (edit.o_start === edit.o_end && edit.o_str === "") { + // Insert an empty string at the insertion index + words.splice(edit.c_start, 0, ""); + } + }); let currentEditIndex = 0 let currentWordIndex = 0