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

0
4 comments

If you need to get contents of VirtualFile as text, you can use

LoadTextUtil.loadText(virtualFile)
0
Avatar
Permanently deleted user

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

 

0

Try getting content of the document, corresponding to your file, it should reflect the state of file represented in editor (see FileDocumentManager.getDocument).

1
Avatar
Permanently deleted user

Now it works, thank you ;)

0

Please sign in to leave a comment.