epm-dev-priporov / idea-notes

Intellij Idea based IDE plugin for making notes in simple and convenient way.
Apache License 2.0
15 stars 6 forks source link

great thank you, I was facing another issue, we dont have expand all, collapse all, Select Opened file #11

Closed Smssyed8 closed 1 year ago

Smssyed8 commented 1 year ago
          great thank you, I was facing another issue, we dont have expand all, collapse all, 

Also, I search a file in hierarchy, on search the file is shown and opens in intellij tab, however doesnt show and point to the file in Notes, explorer. As there are child hierarchy files which I want to open and interested in.

Originally posted by @Smssyed8 in https://github.com/epm-dev-priporov/idea-notes/issues/7#issuecomment-1514322638

Smssyed8 commented 1 year ago

Can we use,

import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFileManager

class OpenInEditorAction(private val tree: NoteTree, value: String? = null) : AnAction(value) {

override fun actionPerformed(e: AnActionEvent) {
    val node = tree.getSelectedNode() ?: return
    val file = node.virtualFile ?: return
    val project = e.project ?: return

    // Open file in editor
    FileEditorManager.getInstance(project).openFile(file, true)

    // Find PsiFile corresponding to the opened file
    val psiFile = file.toPsiFile(project) ?: return

    // Select PsiFile in Project view
    val virtualFile = psiFile.virtualFile
    val virtualFileUrl = virtualFile?.url ?: return
    val projectFile = VirtualFileManager.getInstance().findFileByUrl(virtualFileUrl) ?: return
    projectFile.selectInProjectView()
}

private fun VirtualFile.toPsiFile(project: Project): PsiFile? {
    return PsiManager.getInstance(project).findFile(this)
}

}

epm-dev-priporov commented 1 year ago

this is what I have already noted and tried to do, but got some issue, will try to fix in the upcoming, but help would be appreciated. I also tried to impement "scroll from source" feature -> highlight and select the opened note in explorer by some hotkey, but there were some corner cases which I didn't solvem so it was suspended.

epm-dev-priporov commented 1 year ago

@Smssyed8 I found the following solution. Intellij idea has "Other | Select File in Project View" hotkey, which works for any files and the default behaviour for search is not to navigate to found file. But using this hotkey idea jump to it, so the same feature will be added for the plugin. This is actually what I tried to implement before. Will be released soon, now I am testing it and wait for another issue PR

Smssyed8 commented 1 year ago

That is great

epm-dev-priporov commented 1 year ago

done

Smssyed8 commented 1 year ago

Hmm, is this working? I tested it in the update, but it is not working it seems

epm-dev-priporov commented 1 year ago

Hmm, is this working? I tested it in the update, but it is not working it seems

@Smssyed8 did you assigned the hotkey "Other | Select File in Project View"? it's working

epm-dev-priporov commented 1 year ago

...yes....doesn't work in case when TextEditor is not selected, in case of markdown for example