Closed
Conversation
Fix incorrect replacements when all=true by updating the lowered/normalized searchText after performing a replacement. The function previously derived searchText once from the original text but then modified text during iteration, causing subsequent match indices to be out of sync and leading to skipped or wrong replacements. Recompute searchText (respecting case sensitivity) and advance the search position after each replacement so matches remain aligned with the modified text.
The previous implementation checked the character at the match start/end to decide whole-word boundaries, which produced incorrect results for matches at string edges and adjacent non-word characters. Introduce a helper isWordBoundary(text, index) to encapsulate bounds checking and word-character testing, and replace repeated inline checks with calls to that helper in all affected search/replace/count code paths so whole-word matching behaves correctly.
The isWordBoundary/isWordBoundaryChar functions treated index as a character position and incorrectly considered index<=0 to be a boundary. The logic should treat the provided index as the boundary position between characters, so indexes < 0 or >= text.length should be treated as boundaries and the check should test the character at that index. Update calls to pass index-1 for the preceding boundary so whole-word matching and transcript word highlighting behave correctly.
Fix incorrect mapping of flat string positions to ProseMirror document positions in handleEditorReplace. The previous implementation assumed a +1 offset only for the document node, which did not account for block boundaries (each adds two ProseMirror positions but one character in textBetween). This caused incorrect replacement ranges. - Walk the ProseMirror document using doc.descendants() and build an array of text nodes with their actual ProseMirror positions. - Search within each text node's string (respecting case sensitivity and whole-word options) and record hits using the node's real position plus the match index. - Remove the erroneous +1 offset when applying replacements so adjustedFrom/adjustedTo use the correct ProseMirror positions. These changes ensure replacements target the correct positions across paragraph and block boundaries.
…x.tsx Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Make handleTranscriptReplace build a single concatenated transcript string and locate the Nth match within that full text, then map the match position back to the specific word and offset. This aligns its match counting with getTranscriptMatches so replace operations target the same occurrence the search context identified. The change handles case sensitivity, whole-word checks, supports replacing all matches, and computes the correct occurrence index inside the affected word before calling replaceInText.
✅ Deploy Preview for hyprnote-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for hyprnote ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
No description provided.