Skip to content

Commit e90a249

Browse files
committed
avoid crashing at Undo issues, report the error and do not continue
1 parent 9c56243 commit e90a249

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

app/src/main/kotlin/com/simplemobiletools/notes/fragments/NoteFragment.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ import android.view.View
1616
import android.view.ViewGroup
1717
import android.view.inputmethod.EditorInfo
1818
import androidx.annotation.RequiresApi
19-
import com.simplemobiletools.commons.extensions.beGone
20-
import com.simplemobiletools.commons.extensions.beVisible
21-
import com.simplemobiletools.commons.extensions.onGlobalLayout
22-
import com.simplemobiletools.commons.extensions.removeBit
19+
import com.simplemobiletools.commons.extensions.*
2320
import com.simplemobiletools.notes.R
2421
import com.simplemobiletools.notes.activities.MainActivity
2522
import com.simplemobiletools.notes.extensions.config
@@ -214,7 +211,13 @@ class NoteFragment : androidx.fragment.app.Fragment() {
214211
val end = start + if (edit.after != null) edit.after.length else 0
215212

216213
isUndoOrRedo = true
217-
text.replace(start, end, edit.before)
214+
try {
215+
text.replace(start, end, edit.before)
216+
} catch (e: Exception) {
217+
activity?.showErrorToast(e)
218+
return
219+
}
220+
218221
isUndoOrRedo = false
219222

220223
for (span in text.getSpans(0, text.length, UnderlineSpan::class.java)) {

0 commit comments

Comments
 (0)