Skip to content

Commit

Permalink
fix(web): fix monaco editor key binding (#1809)
Browse files Browse the repository at this point in the history
  • Loading branch information
newfish-cmyk authored Jan 17, 2024
1 parent c3e0bca commit 87b3c03
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions web/src/components/Editor/FunctionEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import {
registerFileSystemOverlay,
} from "vscode/service-override/files";

import { APP_STATUS, COLOR_MODE, Pages, RUNTIMES_PATH } from "@/constants";
import { APP_STATUS, COLOR_MODE, RUNTIMES_PATH } from "@/constants";

import "./useWorker";

import { createUrl, createWebSocketAndStartClient, performInit } from "./LanguageClient";

import { TFunction } from "@/apis/typing";
import useFunctionCache from "@/hooks/useFunctionCache";
import useHotKey, { DEFAULT_SHORTCUTS } from "@/hooks/useHotKey";
import useFunctionStore from "@/pages/app/functions/store";
import useGlobalStore from "@/pages/globalStore";

Expand Down Expand Up @@ -54,16 +53,6 @@ function FunctionEditor(props: {
}
}, [baseUrl]);

useHotKey(
DEFAULT_SHORTCUTS.send_request,
() => {
editorRef.current?.trigger("keyboard", "editor.action.formatDocument", {});
},
{
enabled: globalStore.currentPageId === Pages.function,
},
);

useEffect(() => {
const startLSP = () => {
const lspWebSocket = createWebSocketAndStartClient(url, globalStore.currentApp.develop_token);
Expand Down Expand Up @@ -159,6 +148,10 @@ function FunctionEditor(props: {
scrollBeyondLastLine: false,
value: value,
});
monaco.editor.addKeybindingRule({
keybinding: monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyP,
command: null,
})
});
}

Expand Down

0 comments on commit 87b3c03

Please sign in to comment.