mirror of
https://github.com/chylex/IntelliJ-Keyboard-Master.git
synced 2025-04-18 23:15:44 +02:00
Fix vim-style navigation being active in popups even when disabled
This commit is contained in:
parent
ca075869eb
commit
b131413c8d
src/main/kotlin/com/chylex/intellij/keyboardmaster/feature/vimNavigation
@ -8,7 +8,7 @@ import com.intellij.ui.popup.list.ListPopupImpl
|
||||
|
||||
internal object PopupInterceptor : PersistentUiInterceptor<AbstractPopup>(AbstractPopup::class.java) {
|
||||
override fun shouldIntercept(component: AbstractPopup): Boolean {
|
||||
if (component is ListPopupImpl) {
|
||||
if (component is ListPopupImpl && VimNavigation.isEnabled) {
|
||||
VimListNavigation.install(component.list, component)
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,12 @@ import javax.swing.KeyStroke
|
||||
import javax.swing.UIManager
|
||||
|
||||
object VimNavigation {
|
||||
private val isEnabled = AtomicBoolean(false)
|
||||
private val isEnabledFlag = AtomicBoolean(false)
|
||||
private var originalPopupBindings: Array<*>? = null
|
||||
|
||||
val isEnabled
|
||||
get() = isEnabledFlag.get()
|
||||
|
||||
fun register() {
|
||||
val disposable = ApplicationManager.getApplication().getService(PluginDisposableService::class.java)
|
||||
|
||||
@ -29,7 +32,7 @@ object VimNavigation {
|
||||
}
|
||||
|
||||
fun setEnabled(enabled: Boolean) {
|
||||
if (!isEnabled.compareAndSet(!enabled, enabled)) {
|
||||
if (!isEnabledFlag.compareAndSet(!enabled, enabled)) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -61,7 +64,7 @@ object VimNavigation {
|
||||
}
|
||||
|
||||
private fun handleEvent(event: AWTEvent) {
|
||||
if (event is FocusEvent && event.id == FocusEvent.FOCUS_GAINED && isEnabled.get()) {
|
||||
if (event is FocusEvent && event.id == FocusEvent.FOCUS_GAINED && isEnabled) {
|
||||
when (val source = event.source) {
|
||||
is JList<*> -> VimListNavigation.install(source)
|
||||
is JTree -> VimTreeNavigation.install(source)
|
||||
|
Loading…
Reference in New Issue
Block a user