Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ public CompletableFuture<?> execute(Map<String, Object> properties) {
properties.put(ITerminalsConnectorConstants.PROP_FORCE_NEW, Boolean.TRUE);
}

boolean hadWorkingDirectoryBefore = properties
.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR);
// Initialize the local terminal working directory.
if (!properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR)) {
if (!hadWorkingDirectoryBefore) {
// By default, start the local terminal in the users home directory
String initialCwd = IPreferenceKeys.getPreferences()
.getString(IPreferenceKeys.PREF_LOCAL_TERMINAL_INITIAL_CWD);
Expand Down Expand Up @@ -213,7 +215,7 @@ public CompletableFuture<?> execute(Map<String, Object> properties) {
}
}
}
if (dir != null) {
if (!hadWorkingDirectoryBefore && dir != null) {
properties.put(ITerminalsConnectorConstants.PROP_PROCESS_WORKING_DIR, dir);

String basename = new Path(dir).lastSegment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.atomic.AtomicReference;

import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
Expand Down Expand Up @@ -250,6 +252,7 @@ protected ITerminalConnector createTerminalConnector(Map<String, Object> propert
public CompletableFuture<?> openConsole(final Map<String, Object> properties) {
Assert.isNotNull(properties);
final boolean restoringView = fRestoringView;
AtomicReference<CompletableFuture<?>> endOperation = new AtomicReference<>(null);
return executeServiceOperation(properties, new TerminalServiceRunnable() {
@Override
public void run(TerminalViewId tvid, String title, ITerminalConnector connector, Object data)
Expand All @@ -261,7 +264,14 @@ public void run(TerminalViewId tvid, String title, ITerminalConnector connector,
fRestoringView = true;
consoleViewManager.showConsoleView(tvid);
fRestoringView = false;
doRun(tvid, title, connector, data);

// To make sure that the terminals started by showConsoleView() are started first,
// we have to delay starting the current one with executeServiceOperation()
// (add the operation at the end of the queue)
endOperation.set(executeServiceOperation(
(tvid2, title2, connector2, data2) -> doRun(tvid, title, connector, data), tvid, title,
connector, data));

}
}

Expand Down Expand Up @@ -294,7 +304,8 @@ private void doRun(TerminalViewId tvid, String title, ITerminalConnector connect
console.setData("properties", properties); //$NON-NLS-1$
}
}
});
}).thenCompose(o -> Objects.<CompletableFuture<?>>requireNonNullElse(endOperation.get(),
CompletableFuture.completedFuture(o)));
}

@Override
Expand Down
Loading