Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/note-content-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,18 @@ class NoteContentEditor extends Component<Props> {
this.setDecorators();
}

// If content is changed so that the selected search index is greater then the number of matches
// then select the last match instead
if (
this.editor &&
this.state.editor === 'full' &&
(this.props.selectedSearchMatchIndex ?? 0) > this.matchesInNote.length - 1
) {
const newIndex = Math.max(this.matchesInNote.length - 1, 0);
this.setSearchSelection(newIndex);
this.props.storeSearchSelection(newIndex);
}

if (
this.editor &&
this.state.editor === 'full' &&
Expand Down