Open external files via SDK in text editor
已回答
I am working over plugin for intellij idea and the plugin keeps some files in it's own directory like ~/.plugin/ . The plugin needs to open some files from the directory in text editor, but the existing solutin I found like
val project = ProjectManager.getInstance().openProjects[0]
val textEditor: Editor? = FileEditorManager.getInstance(project).openTextEditor(
OpenFileDescriptor(project, node.file, 0),
true
)
doesn't work. Probably because virtual files out of project. So my question is what the propery way to open such kind of external files?
请先登录再写评论。
Hi,
It should work correctly even for files not being part of the project.
There are two potential issues:
LocalFileSystem.getInstance().findFileByNioFile(Path.of("~/.plugin/my-file.txt"))thank you, the cause was that files were without extension, when I added .txt it correctly works