void (@Nullable VirtualFile fileToOpen) { TerminalTabState state = new TerminalTabState(); VirtualFile parentDirectory = fileToOpen != null && !fileToOpen.isDirectory() ? fileToOpen.getParent() : fileToOpen; if (parentDirectory != null) { state.myWorkingDirectory = parentDirectory.getPath(); } createNewSession(myTerminalRunner, state); }