Fix browser script integration

This commit is contained in:
crschnick 2023-11-24 07:24:02 +00:00
parent df517b9d74
commit 1aadbc3a76
5 changed files with 42 additions and 23 deletions

View file

@ -160,7 +160,7 @@ public final class OpenFileSystemModel {
.getShell()
.get()
.subShell(adjustedPath)
.initWith(new SimpleScriptSnippet(
.withInitSnippet(new SimpleScriptSnippet(
fileSystem
.getShell()
.get()
@ -363,6 +363,9 @@ public final class OpenFileSystemModel {
public void initFileSystem() throws Exception {
BooleanScope.execute(busy, () -> {
var fs = entry.getStore().createFileSystem();
if (fs.getShell().isPresent()) {
ProcessControlProvider.get().withDefaultScripts(fs.getShell().get());
}
fs.open();
this.fileSystem = fs;
this.local = fs.getShell()
@ -392,17 +395,23 @@ public final class OpenFileSystemModel {
}
BooleanScope.execute(busy, () -> {
if (entry.getStore() instanceof ShellStore s) {
var connection = ((ConnectionFileSystem) fileSystem).getShellControl();
var name = directory + " - " + entry.get().getName();
var toOpen = ProcessControlProvider.get().withDefaultScripts(connection);
TerminalHelper.open(
entry.getEntry(),
name,
toOpen.initWith(new SimpleScriptSnippet(connection.getShellDialect().getCdCommand(directory), ScriptSnippet.ExecutionType.BOTH)));
if (fileSystem.getShell().isPresent()) {
var connection = fileSystem.getShell().get();
var snippet = directory != null ? new SimpleScriptSnippet(connection.getShellDialect().getCdCommand(directory),
ScriptSnippet.ExecutionType.BOTH) : null;
if (snippet != null) {
connection.withInitSnippet(snippet);
}
// Restart connection as we will have to start it anyway, so we speed it up by doing it preemptively
connection.start();
try {
var name = (directory != null ? directory + " - " : "") + entry.get().getName();
TerminalHelper.open(entry.getEntry(), name, connection);
// Restart connection as we will have to start it anyway, so we speed it up by doing it preemptively
connection.start();
} finally {
connection.removeInitSnippet(snippet);
}
}
});
});

View file

@ -155,7 +155,9 @@ public interface ShellControl extends ProcessControl {
}
ShellControl elevationPassword(FailableSupplier<SecretValue> value);
ShellControl initWith(ScriptSnippet snippet);
ShellControl withInitSnippet(ScriptSnippet snippet);
ShellControl removeInitSnippet(ScriptSnippet snippet);
ShellControl additionalTimeout(int ms);

16
dist/changelogs/1.7.8.md vendored Normal file
View file

@ -0,0 +1,16 @@
## Changes in 1.7.8
- Make created scripts fully apply to file browser sessions as well
- More startup performance improvements
- Fix dialog window order sometimes being wrong and shown behind main window
- Fix macOS Terminal.app sometimes not launching connection due to a race condition
## Previous changes in 1.7
- [1.7.7](https://github.com/xpipe-io/xpipe/releases/tag/1.7.7)
- [1.7.6](https://github.com/xpipe-io/xpipe/releases/tag/1.7.6)
- [1.7.5](https://github.com/xpipe-io/xpipe/releases/tag/1.7.5)
- [1.7.4](https://github.com/xpipe-io/xpipe/releases/tag/1.7.4)
- [1.7.3](https://github.com/xpipe-io/xpipe/releases/tag/1.7.3)
- [1.7.2](https://github.com/xpipe-io/xpipe/releases/tag/1.7.2)
- [1.7.1](https://github.com/xpipe-io/xpipe/releases/tag/1.7.1)

View file

@ -4,7 +4,6 @@ import io.xpipe.app.browser.BrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.LeafAction;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.TerminalHelper;
import io.xpipe.core.store.FileKind;
import javafx.scene.Node;
import javafx.scene.input.KeyCode;
@ -22,15 +21,8 @@ public class OpenTerminalAction implements LeafAction {
@Override
public void execute(OpenFileSystemModel model, List<BrowserEntry> entries) throws Exception {
if (model.getInOverview().get()) {
TerminalHelper.open(
model.getName(),
model.getFileSystem().getShell().orElseThrow());
return;
}
if (entries.size() == 0) {
model.openTerminalAsync(model.getCurrentDirectory().getPath());
model.openTerminalAsync(model.getCurrentDirectory() != null ? model.getCurrentDirectory().getPath() : null);
return;
}

View file

@ -39,7 +39,7 @@ public abstract class ScriptStore extends JacksonizedValue implements DataStore,
var dir = initScriptsDirectory(shellControl, bringFlattened);
if (dir != null) {
shellControl.initWith(new SimpleScriptSnippet(shellControl.getShellDialect().appendToPathVariableCommand(dir), ScriptSnippet.ExecutionType.TERMINAL_ONLY));
shellControl.withInitSnippet(new SimpleScriptSnippet(shellControl.getShellDialect().appendToPathVariableCommand(dir), ScriptSnippet.ExecutionType.TERMINAL_ONLY));
}
});
return pc;
@ -55,7 +55,7 @@ public abstract class ScriptStore extends JacksonizedValue implements DataStore,
return;
}
pc.initWith(simpleScriptStore);
pc.withInitSnippet(simpleScriptStore);
});
}