Skip to content

Commit 55005b3

Browse files
committed
Add support for launching Eclipse Process in a system terminal session
Currently processes are launched as a forked process without a terminal session attached to them. Some features of processes require a terminal session (e.g. autocompletion) and currently not work when running from within eclipse (e.g. the gogo-shell). This is an attempt to bring terminal session support to Eclipse to support real terminal application similar to what is supported by IntelliJ.
1 parent 0d9f518 commit 55005b3

File tree

3 files changed

+55
-7
lines changed

3 files changed

+55
-7
lines changed

debug/org.eclipse.debug.core/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.debug.core; singleton:=true
5-
Bundle-Version: 3.22.100.qualifier
5+
Bundle-Version: 3.23.0.qualifier
66
Bundle-Activator: org.eclipse.debug.core.DebugPlugin
77
Bundle-Vendor: %providerName
88
Bundle-Localization: plugin

debug/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ public class DebugPlugin extends Plugin {
388388
*/
389389
private static DebugPlugin fgDebugPlugin= null;
390390

391+
static ExecFactory factory;
392+
391393
/**
392394
* The singleton breakpoint manager.
393395
*/
@@ -981,7 +983,13 @@ public static Process exec(String[] cmdLine, File workingDirectory, String[] env
981983
* @since 3.14
982984
*/
983985
public static Process exec(String[] cmdLine, File workingDirectory, String[] envp, boolean mergeOutput) throws CoreException {
984-
Process p = null;
986+
ExecFactory builder;
987+
synchronized (DebugPlugin.class) {
988+
builder = factory;
989+
}
990+
if (builder != null) {
991+
return builder.exec(cmdLine, workingDirectory, envp, mergeOutput);
992+
}
985993
try {
986994
// starting with and without merged output could be done with the
987995
// same process builder approach but since the handling of
@@ -1004,11 +1012,11 @@ public static Process exec(String[] cmdLine, File workingDirectory, String[] env
10041012
}
10051013
}
10061014
}
1007-
p = pb.start();
1015+
return pb.start();
10081016
} else if (workingDirectory == null) {
1009-
p = Runtime.getRuntime().exec(cmdLine, envp);
1017+
return Runtime.getRuntime().exec(cmdLine, envp);
10101018
} else {
1011-
p = Runtime.getRuntime().exec(cmdLine, envp, shortenWindowsPath(workingDirectory));
1019+
return Runtime.getRuntime().exec(cmdLine, envp, shortenWindowsPath(workingDirectory));
10121020
}
10131021
} catch (IOException e) {
10141022
Status status = new Status(IStatus.ERROR, getUniqueIdentifier(), ERROR, DebugCoreMessages.DebugPlugin_0, e);
@@ -1021,11 +1029,11 @@ public static Process exec(String[] cmdLine, File workingDirectory, String[] env
10211029
if (handler != null) {
10221030
Object result = handler.handleStatus(status, null);
10231031
if (result instanceof Boolean resultValue && resultValue) {
1024-
p = exec(cmdLine, null);
1032+
return exec(cmdLine, null);
10251033
}
10261034
}
10271035
}
1028-
return p;
1036+
return null;
10291037
}
10301038

10311039
// https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 Christoph Läubrich and others.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* Christoph Läubrich - initial API and implementation
13+
*******************************************************************************/
14+
package org.eclipse.debug.core;
15+
16+
import java.io.File;
17+
18+
import org.eclipse.core.runtime.CoreException;
19+
20+
/**
21+
* A {@link ExecFactory} can be used to control how Eclipse forks a
22+
* new {@link Process}. As this is a global behavior, only one factory can be
23+
* set for the whole application lifetime.
24+
*
25+
* @since 3.23
26+
*/
27+
public interface ExecFactory {
28+
29+
Process exec(String[] cmdLine, File workingDirectory, String[] envp, boolean mergeOutput) throws CoreException;
30+
31+
static void setDefault(ExecFactory factory) {
32+
synchronized (DebugPlugin.class) {
33+
if (DebugPlugin.factory != null) {
34+
throw new IllegalStateException("A factory was already set for this application"); //$NON-NLS-1$
35+
}
36+
DebugPlugin.factory = factory;
37+
}
38+
}
39+
40+
}

0 commit comments

Comments
 (0)