Skip to content

Commit

Permalink
fix: parse on selected grammar change
Browse files Browse the repository at this point in the history
  • Loading branch information
almahdi404 committed Sep 8, 2024
1 parent 4eed932 commit c666373
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-gifts-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"treeground": patch
---

fix: parse on selected grammar change
3 changes: 2 additions & 1 deletion src/components/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const Editor: Component<Props> = (props) => {
if (editor) {
editor.dispose();
}
props.setEditor(null);
});
if (selectedGrammar) {
createHighlighter({
Expand Down Expand Up @@ -64,6 +63,8 @@ const Editor: Component<Props> = (props) => {
});
props.setEditor(editor);
});
} else {
props.setEditor(null);
}
});

Expand Down
1 change: 1 addition & 0 deletions src/components/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const Nav: Component<{
const handleGrammarChange = (e: Event & { target: HTMLSelectElement }) => {
const value = e.target.value;
if (value) {
props.parseOnNewEditor();
batch(() => {
props.setSelectedGrammar(value);
props.setSelectedHighlighter(
Expand Down
1 change: 0 additions & 1 deletion src/components/TreeGround.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ function App() {

createEffect(() => {
localStorage.setItem("treeground.selectedGrammar", selectedGrammar() || "");
parseOnNewEditor();
});

createEffect(() => {
Expand Down

0 comments on commit c666373

Please sign in to comment.