Skip to content

Commit

Permalink
fixing match not found on first line
Browse files Browse the repository at this point in the history
  • Loading branch information
sereneinserenade committed Oct 25, 2021
1 parent 770bd01 commit 1898e72
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/extension-search-n-replace/src/search-n-replace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,10 @@ function processSearches(doc: ProsemirrorNode, searchTerm: RegExp, searchResultC

for (let j = 0; j < matches.length; j += 1) {
const m = matches[j]

if (m[0] === '') break

if (m.index) {
if (m.index !== undefined) {
results.push({
from: pos + m.index,
to: pos + m.index + m[0].length,
Expand All @@ -98,7 +99,10 @@ function processSearches(doc: ProsemirrorNode, searchTerm: RegExp, searchResultC
}
}

results.forEach(r => decorations.push(Decoration.inline(r.from, r.to, { class: searchResultClass })))
for (let i = 0; i < results.length; i += 1) {
const r = results[i]
decorations.push(Decoration.inline(r.from, r.to, { class: searchResultClass }))
}

return {
decorationsToReturn: DecorationSet.create(doc, decorations),
Expand Down Expand Up @@ -238,7 +242,6 @@ export const SearchNReplace = Extension.create<SearchOptions>({
return decorationsToReturn
}
return DecorationSet.empty

},
},
props: {
Expand Down

0 comments on commit 1898e72

Please sign in to comment.