From 0c47abbc54dcf930dd23164f2b56739a01d9f0fa Mon Sep 17 00:00:00 2001 From: MUedsa <7676275+MUedsa@users.noreply.github.com> Date: Fri, 26 Nov 2021 15:38:12 +0800 Subject: [PATCH] update: positionInChapter=0 when next chapter --- .../intellij/textReader/composes/ReaderWindow.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/muedsa/intellij/textReader/composes/ReaderWindow.java b/src/main/java/com/muedsa/intellij/textReader/composes/ReaderWindow.java index 115b679..f58953a 100644 --- a/src/main/java/com/muedsa/intellij/textReader/composes/ReaderWindow.java +++ b/src/main/java/com/muedsa/intellij/textReader/composes/ReaderWindow.java @@ -358,6 +358,7 @@ private void setTextContent(){ textContent.setText(text); noBlankChapterText = text.replaceAll("\\s*", ""); textContent.setCaretPosition(0); + positionInChapter = 0; } } @@ -370,12 +371,7 @@ public String nextLine(){ int lineSize = (int)lineSizeSpinner.getValue(); if(lineSize > 0){ if(StringUtils.isEmpty(noBlankChapterText) || positionInChapter > noBlankChapterText.length()){ - if(nextChapter()){ - positionInChapter = 0; - noBlankChapterText = textContent.getText(); - }else{ - return "end!"; - } + nextChapter(); } String line = StringUtils.mid(noBlankChapterText, positionInChapter, lineSize); positionInChapter += lineSize; @@ -390,15 +386,12 @@ public String nextLine(){ } } - private boolean nextChapter(){ + private void nextChapter(){ int count = titleList.getItemsCount(); int index = titleList.getSelectedIndex() + 1; if(index + 1 <= count){ titleList.setSelectedIndex(index); setTextContent(); - return true; - }else{ - return false; } } }