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 BetterThanTomorrow#2012
  • Loading branch information
julienvincent committed Jan 9, 2023
1 parent 21304f0 commit 2b2b0ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
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
4 changes: 3 additions & 1 deletion src/custom-snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ type SnippetDefinition = {
export async function evaluateCustomCodeSnippetCommand(
codeOrKeyOrSnippet?: string | SnippetDefinition
) {
await evaluateCodeOrKeyOrSnippet(codeOrKeyOrSnippet);
evaluateCodeOrKeyOrSnippet(codeOrKeyOrSnippet).catch((err) => {
console.log('Failed to run snippet', err);
});
}

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

0 comments on commit 2b2b0ad

Please sign in to comment.