fix(editor): don't show popups if editor is not attached to window (#1752)

This commit is contained in:
Akash Yadav
2024-03-05 10:57:43 +05:30
parent 0801e90130
commit 940c7b0aa2
2 changed files with 11 additions and 1 deletions
@@ -17,6 +17,7 @@
package com.itsaky.androidide.editor.ui
import com.itsaky.androidide.utils.ILogger
import io.github.rosemoe.sora.widget.CodeEditor
import io.github.rosemoe.sora.widget.base.EditorPopupWindow
@@ -28,8 +29,17 @@ import io.github.rosemoe.sora.widget.base.EditorPopupWindow
abstract class AbstractPopupWindow(editor: CodeEditor, features: Int) :
EditorPopupWindow(editor, features) {
companion object {
private val log = ILogger.newInstance("AbstractPopupWindow")
}
override fun show() {
(editor as? IDEEditor)?.ensureWindowsDismissed()
if (!editor.isAttachedToWindow) {
log.error("Trying to show popup window '${javaClass.name}' when editor is not attached to window")
return
}
super.show()
}
@@ -69,7 +69,7 @@ import kotlin.math.min
* @author Akash Yadav
*/
@SuppressLint("RestrictedApi")
open class EditorActionsMenu constructor(val editor: IDEEditor) :
open class EditorActionsMenu(val editor: IDEEditor) :
AbstractPopupWindow(editor, FEATURE_SHOW_OUTSIDE_VIEW_ALLOWED),
ActionsRegistry.ActionExecListener,
MenuBuilder.Callback {