Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/components/options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
parsers,
sourceTypes,
versions,
defaultCode,
} from "@/lib/const";
import { Button } from "./ui/button";
import { Label } from "./ui/label";
Expand Down Expand Up @@ -208,6 +209,13 @@ export const Options: FC = () => {
const language = value as Language;
explorer.setLanguage(language);

if (explorer.code[language] === undefined) {
explorer.setCode({
...explorer.code,
[language]: defaultCode[language],
});
}

Comment on lines +212 to +218
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to handle this scenario in the use-explorer.ts file I guess.

if (language !== "javascript" && explorer.tool !== "ast") {
explorer.setTool("ast");
}
Expand Down