Skip to content

Commit

Permalink
throw error when the selection is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardoj committed Jan 7, 2025
1 parent ce50265 commit ad6ca17
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/MarkdownTextInput.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,7 @@ const MarkdownTextInput = React.forwardRef<MarkdownTextInput, MarkdownTextInputP
const handleFormatSelection = useCallback(
(target: MarkdownTextInputElement, parsedText: string, cursorPosition: number, formatCommand: string): ParseTextResult => {
if (!contentSelection.current || contentSelection.current.end - contentSelection.current.start < 1) {
return {
text: '',
cursorPosition: 0,
};
throw new Error('[react-native-live-markdown] invalid selection');
}

const selectedText = parsedText.slice(contentSelection.current.start, contentSelection.current.end);
Expand Down

0 comments on commit ad6ca17

Please sign in to comment.