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

Commit 940c7b0

Browse files
committed
fix(editor): don't show popups if editor is not attached to window (#1752)
1 parent 0801e90 commit 940c7b0

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

editor/src/main/java/com/itsaky/androidide/editor/ui/AbstractPopupWindow.kt

+10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.itsaky.androidide.editor.ui
1919

20+
import com.itsaky.androidide.utils.ILogger
2021
import io.github.rosemoe.sora.widget.CodeEditor
2122
import io.github.rosemoe.sora.widget.base.EditorPopupWindow
2223

@@ -28,8 +29,17 @@ import io.github.rosemoe.sora.widget.base.EditorPopupWindow
2829
abstract class AbstractPopupWindow(editor: CodeEditor, features: Int) :
2930
EditorPopupWindow(editor, features) {
3031

32+
companion object {
33+
private val log = ILogger.newInstance("AbstractPopupWindow")
34+
}
35+
3136
override fun show() {
3237
(editor as? IDEEditor)?.ensureWindowsDismissed()
38+
if (!editor.isAttachedToWindow) {
39+
log.error("Trying to show popup window '${javaClass.name}' when editor is not attached to window")
40+
return
41+
}
42+
3343
super.show()
3444
}
3545

editor/src/main/java/com/itsaky/androidide/editor/ui/EditorActionsMenu.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ import kotlin.math.min
6969
* @author Akash Yadav
7070
*/
7171
@SuppressLint("RestrictedApi")
72-
open class EditorActionsMenu constructor(val editor: IDEEditor) :
72+
open class EditorActionsMenu(val editor: IDEEditor) :
7373
AbstractPopupWindow(editor, FEATURE_SHOW_OUTSIDE_VIEW_ALLOWED),
7474
ActionsRegistry.ActionExecListener,
7575
MenuBuilder.Callback {

0 commit comments

Comments
 (0)