mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-18 06:22:28 +03:00
editor singleton added
This commit is contained in:
parent
21d59b5e05
commit
908c6cdff7
@ -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<string>(
|
||||
'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);
|
||||
}
|
||||
);
|
||||
|
23
app/src/lib/utils/systemEditor.ts
Normal file
23
app/src/lib/utils/systemEditor.ts
Normal file
@ -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 };
|
Loading…
Reference in New Issue
Block a user