#209 Workspace can be opened from command line

This commit is contained in:
Vitaly Livshic 2017-08-08 07:27:32 +03:00
parent 0cd202d43f
commit 34507bc622
2 changed files with 25 additions and 4 deletions

View File

@ -86,7 +86,16 @@ extern (C) int UIAppMain(string[] args) {
//pragma(msg, w.click.return_t, "", w.click.params_t);
IDEFrame frame = new IDEFrame(window);
// Open project, if it specified in command line
if (args.length > 1)
{
Action a = ACTION_FILE_OPEN_WORKSPACE.clone();
a.stringParam = args[1];
frame.handleAction(a);
// Mark that workspace opened to prevent auto open
frame.isOpenedWorkspace(true);
}
// open home screen tab
frame.showHomeScreen();
@ -185,4 +194,4 @@ unittest {
loaded.save("test_file2.json");
}
}
}

View File

@ -82,6 +82,8 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
OutputPanel _logPanel;
DockHost _dockHost;
TabWidget _tabs;
// Is any workspace already opened?
private auto openedWorkspace = false;
///Cache for parsed D files for autocomplete and symbol finding
import dlangide.tools.d.dcdinterface;
@ -131,6 +133,16 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
@property bool isExecutionActive() {
return _execution !is null;
}
/// Is any workspace already opened?
@property bool isOpenedWorkspace() {
return openedWorkspace;
}
/// Is any workspace already opened?
@property void isOpenedWorkspace(bool opened) {
openedWorkspace = opened;
}
/// called when program execution is stopped
protected void onProgramExecutionStatus(ProgramExecution process, ExecutionStatus status, int exitCode) {
@ -460,9 +472,9 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
_tabs.addTab(home, UIString.fromId("HOME"c), null, true);
_tabs.selectTab(HOME_SCREEN_ID, true);
auto _settings = new IDESettings(buildNormalizedPath(settingsDir, "settings.json"));
// Auto open last project
// Auto open last workspace, if no workspace specified in command line and autoOpen flag set to true
const auto recentWorkspaces = settings.recentWorkspaces;
if (recentWorkspaces.length > 0 && _settings.autoOpenLastProject())
if (!openedWorkspace && recentWorkspaces.length > 0 && _settings.autoOpenLastProject())
{
Action a = ACTION_FILE_OPEN_WORKSPACE.clone();
a.stringParam = recentWorkspaces[0];