diff --git a/src/store/useFile.ts b/src/store/useFile.ts index 4395ff0..682c552 100644 --- a/src/store/useFile.ts +++ b/src/store/useFile.ts @@ -100,11 +100,12 @@ const useFile = create()((set, get) => ({ try { const contentJson = await contentToJson(get().contents, get().format); const jsonContent = await jsonToContent(JSON.stringify(contentJson, null, 2), format); - set({ format }); get().setContents({ contents: jsonContent, hasChanges: false }); } catch (error) { get().clear(); console.info("The content was unable to be converted, so it was cleared instead."); + } finally { + set({ format }); } }, setContents: async ({ contents, hasChanges = true, skipUpdate = false }) => {