@setoelkahfi / svara / commits / 2a7bb74

fix: keybind input functions now work outside the editor

mellbacon committed Jul 20, 2023 at 18:04 UTC 2a7bb745845c7c9005e26ac2c9649cbe3f2dc3ed
1 file changed +11 -1
src/config/config.ts
+11 -1
@@ -6,6 +6,7 @@ import { loadTheme } from "./themehandler";
6 import { Store } from "tauri-plugin-store-api";
7 import { setEditorFontFamily, setEditorFontSize } from "../lib/Editor.svelte";
8 import { watch } from "tauri-plugin-fs-watch-api";
9 +import { getActiveTab } from "../lib/EditorTabList.svelte";
10
11 export const systemfonts = writable([]);
12 export const editorfont = writable("");
@@ -49,7 +50,16 @@ export async function getShortcuts() {
50 const shortcuts = getKeybinds();
51 for (const shortcut of shortcuts) {
52 const keybind = parseKeybind(shortcut.keybind);
52 - Mousetrap.bind(keybind, async (e) => {e.preventDefault(); await fireAction(shortcut.command)});
53 + Mousetrap.bind(keybind, async (e) => {
54 + // prevent editor functions firing outside editor instances
55 + if (getActiveTab().isfile) {
56 + e.preventDefault();
57 + }
58 + else {
59 + return;
60 + }
61 + await fireAction(shortcut.command);
62 + });
63 }
64 }
65