Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Adds null protection around maps

AuthorDaveJarvis <email>
Date2023-08-02 15:30:32 GMT-0700
Commitaa4da7fd36f73211fe366fb2aa99756ed5053131
Parent4c3c342
Delta3 lines added, 2 lines removed, 1-line increase
src/main/java/com/keenwrite/ui/spelling/TextEditorSpellChecker.java
// paragraph, instead.
if( text.isBlank() ) {
- final var paragraphs = editor.getParagraphs().size();
+ final var paragraphs = editor.getParagraphs();
+ final var count = paragraphs == null ? 0 : paragraphs.size();
- paraId = Math.min( paraId + 1, paragraphs - 1 );
+ paraId = Math.min( paraId + 1, count - 1 );
paragraph = editor.getParagraph( paraId );
text = paragraph.getText();