diff --git a/app/src/lib/components/ProjectSettingsMenuAction.svelte b/app/src/lib/components/ProjectSettingsMenuAction.svelte index b3dfd29c0..c7ef021d9 100644 --- a/app/src/lib/components/ProjectSettingsMenuAction.svelte +++ b/app/src/lib/components/ProjectSettingsMenuAction.svelte @@ -2,8 +2,8 @@ import { listen } from '$lib/backend/ipc'; import { Project } from '$lib/backend/projects'; import { getContext } from '$lib/utils/context'; + import { editor } from '$lib/utils/systemEditor'; import { open } from '@tauri-apps/api/shell'; - import { invoke } from '@tauri-apps/api/tauri'; import { onMount } from 'svelte'; import { goto } from '$app/navigation'; @@ -17,8 +17,7 @@ const unsubscribeOpenInVSCode = listen( 'menu://project/open-in-vscode/clicked', async () => { - const editor = await invoke('resolve_vscode_variant'); - const path = `${editor}://file${project.path}`; + const path = `${editor.get()}://file${project.path}`; open(path); } ); diff --git a/app/src/lib/utils/systemEditor.ts b/app/src/lib/utils/systemEditor.ts new file mode 100644 index 000000000..36f386179 --- /dev/null +++ b/app/src/lib/utils/systemEditor.ts @@ -0,0 +1,23 @@ +import { invoke } from '@tauri-apps/api/tauri'; + +class SystemEditor { + constructor() { + this.resolveEditorVariant(); + } + + static instance = new SystemEditor(); + + private systemEditor = ''; + + async resolveEditorVariant() { + this.systemEditor = (await invoke('resolve_vscode_variant')) as string; + } + + get() { + return this.systemEditor; + } +} + +const editor = SystemEditor.instance; + +export { editor };