Skip to content

Commit

Permalink
fix: Incorrect editor selected in split panes #13
Browse files Browse the repository at this point in the history
Fixes #13
  • Loading branch information
bric3 committed Sep 10, 2021
1 parent dadb9a8 commit e27c365
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# excalidraw-jetbrains-plugin Changelog

## [Unreleased]
## [0.3.2-eap] - 2021-08-12
### Fixed
- Incorrect editor selected in split panes ([#11](https://github.com/bric3/excalidraw-jetbrains-plugin/issues/13))

## [0.3.1-eap] - 2021-08-12
### Fixed
- Fixed compatibility issue with 2021.1.x
Expand Down
2 changes: 1 addition & 1 deletion plugin/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pluginGroup = com.github.bric3.excalidrawjetbrainsplugin
pluginName = excalidraw-jetbrains-plugin
pluginVersion = 0.3.1-eap
pluginVersion = 0.3.2-eap

# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
Expand Down
9 changes: 8 additions & 1 deletion plugin/src/main/kotlin/com/github/bric3/excalidraw/utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import com.intellij.notification.Notification
import com.intellij.notification.NotificationType
import com.intellij.notification.Notifications
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiFile
import org.jetbrains.concurrency.AsyncPromise
import java.io.IOException

Expand All @@ -29,7 +31,12 @@ val debugMode = ProcessHandle.current().info().arguments().map {
*/
fun AnActionEvent.findEditor(): ExcalidrawEditor? {
val project = this.project ?: return null
return FileEditorManager.getInstance(project).selectedEditor as? ExcalidrawEditor ?: return null
val psiFile = (this.dataContext.getData(CommonDataKeys.PSI_FILE) as PsiFile)
val editor = FileEditorManager.getInstance(project).selectedEditors.find {
psiFile.virtualFile.equals(it.file)
}

return editor as? ExcalidrawEditor ?: return null
}


Expand Down

0 comments on commit e27c365

Please sign in to comment.