A Better Split Horizontal

I am trying to implement an api action similar to the existing "Split Horizontal". I have gotten to a point where I have the current file, and I think I am creating a new editor properly using fileEditorManager.openFile(). What I don't see is:

1.) How do I add the new editor to the currently visible editors?

2.) How can I scroll a specific location in the document of the new editor to visible?

Thanks.

Here is my code so far:

public void execute(Editor editor, DataContext dataContext) {
Project project = editor.getProject();
FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
VirtualFile[] currentFiles = fileEditorManager.getSelectedFiles();
if(currentFiles.length == 1 && currentFiles[0] != null){
VirtualFile file = currentFiles[0];
FileEditor[] fileEditors = fileEditorManager.openFile(file, true);
// How do I show the new editor?
// How do I scroll the document to the same location as the cursor in the
// current editor
}
}

0

Please sign in to leave a comment.