Skip to content

Commit

Permalink
Don't block on snippet evaluation
Browse files Browse the repository at this point in the history
If a snippet is evaluated with runCustomREPLCommand and it blocks (due
to a bug or some such) then the editor almost completely deadlocks.

This commit changes the command handler for `runCustomREPLCommand` to
not block on snippet evaluation.

Fixes #2012
  • Loading branch information
julienvincent committed Jan 9, 2023
1 parent 21304f0 commit 8a8f8c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 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]

- Fix: [Evaluating blocking snippets deadlocks the editor](https://github.com/BetterThanTomorrow/calva/issues/2012)

## [2.0.323] - 2023-01-07

- Fix: [Provider completions not handling errors gracefully](https://github.com/BetterThanTomorrow/calva/issues/2006)
Expand Down
8 changes: 4 additions & 4 deletions src/custom-snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ type SnippetDefinition = {
evaluationSendCodeToOutputWindow?: boolean;
};

export async function evaluateCustomCodeSnippetCommand(
codeOrKeyOrSnippet?: string | SnippetDefinition
) {
await evaluateCodeOrKeyOrSnippet(codeOrKeyOrSnippet);
export function evaluateCustomCodeSnippetCommand(codeOrKeyOrSnippet?: string | SnippetDefinition) {
evaluateCodeOrKeyOrSnippet(codeOrKeyOrSnippet).catch((err) => {
console.log('Failed to run snippet', err);
});
}

async function evaluateCodeOrKeyOrSnippet(codeOrKeyOrSnippet?: string | SnippetDefinition) {
Expand Down

0 comments on commit 8a8f8c2

Please sign in to comment.