Skip to content

Commit 6c10766

Browse files
committed
style: fix lint
1 parent e3c22b2 commit 6c10766

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

packages/find-replace/src/lib/__tests__/decorateSearchHighlight/search/empty.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ it('should be', () => {
1616
expect(
1717
decorateFindReplace({
1818
...getEditorPlugin(editor, FindReplacePlugin),
19-
entry: [{ type: 'p', children: [{ text: '' }] }, [0]],
19+
entry: [{ children: [{ text: '' }], type: 'p' }, [0]],
2020
})
2121
).toEqual(output);
2222
});

packages/find-replace/src/lib/__tests__/decorateSearchHighlight/search/text.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ it('should decorate matching text', () => {
1515
expect(
1616
plugin.decorate?.({
1717
...getEditorPlugin(editor, plugin),
18-
entry: [{ type: 'p', children: [{ text: 'test' }] }, [0]],
18+
entry: [{ children: [{ text: 'test' }], type: 'p' }, [0]],
1919
})
2020
).toEqual([
2121
{
@@ -45,7 +45,7 @@ it('should decorate matching text case-insensitively', () => {
4545
expect(
4646
plugin.decorate?.({
4747
...getEditorPlugin(editor, plugin),
48-
entry: [{ type: 'p', children: [{ text: 'test' }] }, [0]],
48+
entry: [{ children: [{ text: 'test' }], type: 'p' }, [0]],
4949
})
5050
).toEqual([
5151
{
@@ -76,7 +76,7 @@ it('should decorate matching consecutive text nodes', () => {
7676
plugin.decorate?.({
7777
...getEditorPlugin(editor, plugin),
7878
entry: [
79-
{ type: 'p', children: [{ text: 'tes' }, { text: 't', bold: true }] },
79+
{ children: [{ text: 'tes' }, { bold: true, text: 't' }], type: 'p' },
8080
[0],
8181
],
8282
})
@@ -122,12 +122,12 @@ it('should decorate matching multiple occurrences', () => {
122122
...getEditorPlugin(editor, plugin),
123123
entry: [
124124
{
125-
type: 'p',
126125
children: [
127126
{ text: 'tes' },
128-
{ text: 'ts and tests and t', bold: true },
127+
{ bold: true, text: 'ts and tests and t' },
129128
{ text: 'ests' },
130129
],
130+
type: 'p',
131131
},
132132
[0],
133133
],

packages/find-replace/src/lib/decorateFindReplace.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ export const decorateFindReplace: Decorate<FindReplaceConfig> = ({
2222

2323
let start = 0;
2424
const matches: number[] = [];
25+
2526
while ((start = str.indexOf(searchLower, start)) !== -1) {
2627
matches.push(start);
2728
start += searchLower.length;
2829
}
2930

30-
if (!matches.length) {
31+
if (matches.length === 0) {
3132
return [];
3233
}
3334

@@ -47,6 +48,7 @@ export const decorateFindReplace: Decorate<FindReplaceConfig> = ({
4748
// If the match ends before the start of the current text, move to the next match
4849
if (matchEnd <= textStart) {
4950
matchIndex++;
51+
5052
continue;
5153
}
5254

@@ -66,18 +68,17 @@ export const decorateFindReplace: Decorate<FindReplaceConfig> = ({
6668

6769
ranges.push({
6870
anchor: {
69-
path: textNodePath,
7071
offset: anchorOffset,
72+
path: textNodePath,
7173
},
7274
focus: {
73-
path: textNodePath,
7475
offset: focusOffset,
76+
path: textNodePath,
7577
},
76-
search: search.substring(searchOverlapStart, searchOverlapEnd),
78+
search: search.slice(searchOverlapStart, searchOverlapEnd),
7779
[type]: true,
7880
});
7981
}
80-
8182
// If the match ends within the current text, move to the next match
8283
if (matchEnd <= textEnd) {
8384
matchIndex++;

0 commit comments

Comments
 (0)