how to get the Editor from PsiElement?

hi ahh
i want the editor instance which is active now
DataManager didnot give but NULL
so i tried the following

Document document = PsiDocumentManager.getInstance(getElement().getProject()).getDocument(getElement().getContainingFile());
Editor editor= EditorFactory.getInstance().getEditors(document,getElement().getProject())[0];

but the editor array is 0 length and the document is not writable
by the way ,this is not accessed from an action so dataContext is not an option ;and obtaining it through DataManager result in nulls
thanks

4 comments
Comment actions Permalink

Hello joe,

j> i want the editor instance which is active now

FileEditorManager.getInstance().getSelectedTextEditor()

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


1
Comment actions Permalink

and if there is no selected text ?is it works also?

0
Comment actions Permalink

Hello joe,

j> and if there is no selected text ?is it works also?

It's not "get editor for selected text", it's "get text editor which is selected".

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

ok,i may need some english lessons :) thanks

0

Please sign in to leave a comment.