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

Commit

Permalink
fix(editor): don't show popups if editor is not attached to window (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
itsaky committed Mar 5, 2024
1 parent 0801e90 commit 940c7b0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 940c7b0

Please sign in to comment.