Improve fallback shell terminal handling

This commit is contained in:
crschnick 2024-03-07 01:51:57 +00:00
parent 84700d2a27
commit 0de5d9da4e
2 changed files with 14 additions and 7 deletions

View file

@ -404,9 +404,7 @@ public class AppPrefs {
if (externalEditor.get() == null) {
ExternalEditorType.detectDefault();
}
if (terminalType.get() == null) {
terminalType.set(ExternalTerminalType.determineDefault());
}
terminalType.set(ExternalTerminalType.determineDefault(terminalType.get()));
}
public Comp<?> getCustomComp(String id) {

View file

@ -33,7 +33,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
@Override
protected CommandBuilder toCommand(LaunchConfiguration configuration) {
if (configuration.getScriptDialect().equals(ShellDialects.CMD)) {
return CommandBuilder.of().add("/c").add(configuration.getScriptFile());
return CommandBuilder.of().add("/c").addFile(configuration.getScriptFile());
}
return CommandBuilder.of().add("/c").add(configuration.getDialectLaunchCommand());
@ -58,7 +58,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
return CommandBuilder.of()
.add("-ExecutionPolicy", "Bypass")
.add("-File")
.add(configuration.getScriptFile());
.addFile(configuration.getScriptFile());
}
return CommandBuilder.of().add("-Command").add(configuration.getDialectLaunchCommand());
@ -83,7 +83,7 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
return CommandBuilder.of()
.add("-ExecutionPolicy", "Bypass")
.add("-File")
.add(configuration.getScriptFile());
.addFile(configuration.getScriptFile());
}
// Fix for https://github.com/PowerShell/PowerShell/issues/18530#issuecomment-1325691850
@ -754,7 +754,16 @@ public interface ExternalTerminalType extends PrefsChoiceValue {
})
.get();
static ExternalTerminalType determineDefault() {
static ExternalTerminalType determineDefault(ExternalTerminalType existing) {
// Check for incompatibility with fallback shell
if (ExternalTerminalType.CMD.equals(existing) && !ProcessControlProvider.get().getEffectiveLocalDialect().equals(ShellDialects.CMD)) {
return ExternalTerminalType.POWERSHELL;
}
if (existing != null) {
return existing;
}
return ALL.stream()
.filter(externalTerminalType -> !externalTerminalType.equals(CUSTOM))
.filter(terminalType -> terminalType.isAvailable())