Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
fix: handle cases where editor might be null when RedoAction is execu…
Browse files Browse the repository at this point in the history
…ted (fixes #1318)
  • Loading branch information
itsaky committed Sep 18, 2023
1 parent ace83d5 commit 2a306e8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/src/main/java/com/itsaky/androidide/actions/text/RedoAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.blankj.utilcode.util.KeyboardUtils
import com.itsaky.androidide.resources.R
import com.itsaky.androidide.actions.ActionData
import com.itsaky.androidide.actions.EditorRelatedAction
import com.itsaky.androidide.actions.markInvisible

/** @author Akash Yadav */
class RedoAction(context: Context, override val order: Int) : EditorRelatedAction() {
Expand All @@ -43,12 +44,20 @@ class RedoAction(context: Context, override val order: Int) : EditorRelatedActio
return
}

val editor = getEditor(data)!!
val editor = getEditor(data) ?: run {
markInvisible()
return
}

enabled = editor.canRedo()
}

override fun execAction(data: ActionData): Boolean {
val editor = getEditor(data)!!
val editor = getEditor(data) ?: run {
markInvisible()
return false
}

editor.redo()
data.getActivity()?.invalidateOptionsMenu()
return true
Expand Down

0 comments on commit 2a306e8

Please sign in to comment.