Skip to content

Commit

Permalink
Run jack-in command in a shubshell, including cwd
Browse files Browse the repository at this point in the history
* Fix #2147
  • Loading branch information
PEZ committed Apr 10, 2023
1 parent 4df1c83 commit 78b6f52
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changes to Calva.

## [Unreleased]

- [Include a change directory command with the jack-in command line](https://github.com/BetterThanTomorrow/calva/issues/2147)

## [2.0.349] - 2023-04-09

- Fix: [Indenter and formatter do not agree on some simple forms (and the formatter is right)](https://github.com/BetterThanTomorrow/calva/issues/2148)
Expand Down
13 changes: 4 additions & 9 deletions src/nrepl/jack-in-terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export interface JackInTerminalOptions extends vscode.TerminalOptions {
useShell: boolean;
}

export function createCommandLine(executable: string, args: string[]) {
return `${executable} ${args.join(' ')}`;
export function createCommandLine(options: JackInTerminalOptions): string {
return `(cd ${options.cwd} && ${options.executable} ${options.args.join(' ')})`;
}

export class JackInTerminal implements vscode.Pseudoterminal {
Expand All @@ -32,12 +32,7 @@ export class JackInTerminal implements vscode.Pseudoterminal {
) {}

open(initialDimensions: vscode.TerminalDimensions | undefined): void {
outputWindow.appendLine(
`; Starting Jack-in Terminal: ${createCommandLine(
this.options.executable,
this.options.args
)}`
);
outputWindow.appendLine(`; Starting Jack-in Terminal: ${createCommandLine(this.options)}`);
this.writeEmitter.fire(
'This is a pseudo terminal, only used for hosting the Jack-in REPL process. It takes no input.\r\nPressing ctrl+c with this terminal focused, killing this terminal, or closing/reloading the VS Code window will all stop/kill the Jack-in REPL process.\r\n\r\n'
);
Expand Down Expand Up @@ -69,7 +64,7 @@ export class JackInTerminal implements vscode.Pseudoterminal {

private async startClojureProgram(): Promise<child.ChildProcess> {
return new Promise<child.ChildProcess>(() => {
const data = `${createCommandLine(this.options.executable, this.options.args)}\r\n`;
const data = `${createCommandLine(this.options)}\r\n`;
this.writeEmitter.fire('⚡️Starting the REPL ⚡️ using the below command line:\r\n');
this.writeEmitter.fire(data);
if (this.process && !this.process.killed) {
Expand Down
6 changes: 3 additions & 3 deletions src/nrepl/jack-in.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ export async function copyJackInCommandToClipboard(): Promise<void> {
}
if (projectConnectSequence) {
try {
const { executable, args } = await getJackInTerminalOptions(projectConnectSequence);
if (executable && args) {
void vscode.env.clipboard.writeText(createCommandLine(executable, args));
const options = await getJackInTerminalOptions(projectConnectSequence);
if (options) {
void vscode.env.clipboard.writeText(createCommandLine(options));
void vscode.window.showInformationMessage('Jack-in command line copied to the clipboard.');
}
} catch (e) {
Expand Down

0 comments on commit 78b6f52

Please sign in to comment.