Skip to content

Commit

Permalink
Prevent project reevaluation during typing.
Browse files Browse the repository at this point in the history
  • Loading branch information
amyjko committed Aug 3, 2024
1 parent e41111d commit 2cf6729
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Dates are in `YYYY-MM-DD` format and versions are in [semantic versioning](http:
### Fixed

- Repaired borrowed bindings from other sources.
- Prevent project reevaluation during typing.

## 0.10.7 2024-07-27

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wordplay",
"version": "0.10.6",
"version": "0.10.8",
"scripts": {
"postinstall": "run-script-os",
"postinstall:default": "svelte-kit sync && cp .env.template .env",
Expand Down
2 changes: 1 addition & 1 deletion src/components/output/OutputView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@
filter,
ease-in,
height ease-in;
transition-duration: calc(var(--animation-factor) * 200ms);
transition-duration: calc(var(--animation-factor) * 500ms);
/** Query the container size */
container-type: inline-size;
Expand Down
20 changes: 10 additions & 10 deletions src/components/project/ProjectView.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script context="module" lang="ts">
export const TYPING_DELAY = 300;
export const TYPING_DELAY = 500;
</script>

<script lang="ts">
Expand Down Expand Up @@ -232,21 +232,17 @@
/** Keep a currently selected output locale to send to the Evaluator for evaluation and rendering */
let evaluationLocale: Locale | undefined = undefined;
/** When the evaluation locale changes, update the evaluator. */
$: if (evaluationLocale === undefined || evaluationLocale !== undefined)
updateEvaluator(project);
/** Keep track of locales used */
$: localesUsed = project.getLocalesUsed();
// When keyboard edit idle changes to true, set a timeout
// When keyboard isn't idle, set a timeout to set it to idle later.
// to reset it to false after a delay.
$: {
if ($keyboardEditIdle !== IdleKind.Idle) {
if (keyboardIdleTimeout) clearTimeout(keyboardIdleTimeout);
keyboardIdleTimeout = setTimeout(
() => keyboardEditIdle.set(IdleKind.Idle),
500,
TYPING_DELAY,
);
}
}
Expand Down Expand Up @@ -322,7 +318,9 @@
() => updateEvaluator(newProject),
TYPING_DELAY,
);
} else updateEvaluator(newProject);
} else {
updateEvaluator(newProject);
}
});
// When the locales change, reset the evaluator to use the new locales.
Expand Down Expand Up @@ -1392,8 +1390,10 @@
{#if localesUsed.length > 1}<OutputLocaleChooser
{localesUsed}
locale={evaluationLocale}
change={(locale) =>
(evaluationLocale = locale)}
change={(locale) => {
evaluationLocale = locale;
updateEvaluator(project);
}}
/>{/if}
<!-- {#if !$evaluation.evaluator.isPlaying()}
<Painting
Expand Down

0 comments on commit 2cf6729

Please sign in to comment.