How to get modified source code from default editor to custom editor?
Hi,
I am developing a IntelliJ plugin where I am using FileEditorProvider to provide another one editor tab. Everything works and my implementations of FileEditorProvider works and UI works also. I don't want to create a listener for each change in source code, but I'd like to get actual source code in button action in custom editor UI. In FileEditorProvider I saved a VirtualFile object to my FileEditor implementation. And now I'd like to get actual source of this virtual file when I change a text there.
Can I ask you for help how to handle these file changes (without saving file) when I am using custom file editor together with default editor?
Many thanks,
Ales
Please sign in to leave a comment.
If you need to get contents of VirtualFile as text, you can use
Hi Dmitry,
I am using getInputStream because I need to use delimeter. But both works in the same way. I tried to use LoadTextUtil also, but still I have a problem to get updated content.
In custom editor UI I have a button which need the latest content from the default editor tab. It works when I change it, save file and then try this action. But I'd like to avoid to saving all the time.
I also provided screenshot, I hope it will be more clear what I have on my mind,
Thanks
Try getting content of the document, corresponding to your file, it should reflect the state of file represented in editor (see FileDocumentManager.getDocument).
Now it works, thank you ;)