Skip to content

Comments

fix: update search implementation#3825

Closed
goranmoomin wants to merge 14 commits intomainfrom
fix/update-search-implementation
Closed

fix: update search implementation#3825
goranmoomin wants to merge 14 commits intomainfrom
fix/update-search-implementation

Conversation

@goranmoomin
Copy link
Collaborator

No description provided.

ComputelessComputer and others added 14 commits February 10, 2026 18:47
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.
@netlify
Copy link

netlify bot commented Feb 10, 2026

Deploy Preview for hyprnote-storybook ready!

Name Link
🔨 Latest commit d21da52
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote-storybook/deploys/698b0d5f09a6bf0008499ba8
😎 Deploy Preview https://deploy-preview-3825--hyprnote-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Feb 10, 2026

Deploy Preview for hyprnote ready!

Name Link
🔨 Latest commit d21da52
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote/deploys/698b0d5f64cc270008eb5d56
😎 Deploy Preview https://deploy-preview-3825--hyprnote.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants