Skip to content

The 'calva.loadFile' command returns a Promise that is only completed on the first execution. #2981

@jurjanpaul

Description

@jurjanpaul

I am sure this counts as a minor issue as VS Code itself does not care about this for normal operations.

But when called from Joyride (or from another extension, for which I only have a very experimental personal use case for now) with await, you get stuck.

Reproducing Joyride user script (JavaScript):

const vscode = require("vscode");

async function run() {
  const output = vscode.window.createOutputChannel("My Joyride script");
  output.appendLine("Executing calva.loadFile");
  output.show(true);
  await vscode.commands.executeCommand("calva.loadFile");
  output.appendLine("Done executing calva.loadFile");
  output.show(true);

  // Do something else after calva.loadFile is finished.
}

run();

When run with an active REPL with a regular Clojure file open, this will output:

Executing calva.loadFile
Done executing calva.loadFile

initially.
But when run again (and again, etc.), it will only output:

Executing calva.loadFile

and not get beyond the await.


This seems to be caused by loadFileCommand in 'evaluate.ts' returning a Promise that invokes output.replWindowAppendPrompt(resolve); that does not really expect a Promise (certainly does not always call resolve, which is called onAppended inside replWindowAppendPrompt, which communicates another expectation.)

Unfortunately, I am not at all sure how this mismatch should best be taken care of.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions