diff --git a/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentViewModel.kt b/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentViewModel.kt index b23a2131f..acbda4f27 100644 --- a/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentViewModel.kt @@ -75,10 +75,13 @@ class SearchContentViewModel(application: Application) : BaseViewModel(applicati private fun searchPosition(pattern: String): List { val position: MutableList = mutableListOf() - if (mContent.indexOf(pattern) >= 0) { + var index = mContent.indexOf(pattern) + if (index >= 0) { //搜索到内容允许净化 - if (book?.getUseReplaceRule() ?: false) mContent = contentProcessor!!.replaceContent(mContent) - var index = mContent.indexOf(pattern) + if (book!!.getUseReplaceRule()) { + mContent = contentProcessor!!.replaceContent(mContent) + index = mContent.indexOf(pattern) + } while (index >= 0) { position.add(index) index = mContent.indexOf(pattern, index + 1)