소스 검색

修改格式化快捷键为`Ctrl+Alt+L`

mxd 3 년 전
부모
커밋
cc6bd02da9
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      magic-editor/src/console/src/components/editor/magic-script-editor.vue

+ 6 - 0
magic-editor/src/console/src/components/editor/magic-script-editor.vue

@@ -74,6 +74,7 @@ import {Parser} from '@/scripts/parsing/parser.js'
 import tokenizer from '@/scripts/parsing/tokenizer.js'
 import {TokenStream} from '@/scripts/parsing/index.js'
 import RequestParameter from '@/scripts/editor/request-parameter.js';
+import { CommandsRegistry } from 'monaco-editor/esm/vs/platform/commands/common/commands'
 
 export default {
   name: 'MagicScriptEditor',
@@ -131,6 +132,11 @@ export default {
         },
         '!findWidgetVisible && !inreferenceSearchEditor && !editorHasSelection'
     )
+    this.editor._standaloneKeybindingService.addDynamicKeybinding(`-editor.action.formatDocument`, undefined, () => {})
+    const { handler, when } = CommandsRegistry.getCommand('editor.action.formatDocument') ?? {}
+    if (handler) {
+      this.editor._standaloneKeybindingService.addDynamicKeybinding('editor.action.formatDocument', monaco.KeyMod.CtrlCmd | monaco.KeyMod.Alt | monaco.KeyCode.KEY_L, handler, when)
+    }
     this.editor.onMouseDown(e => {
       if (e.target.element.classList.contains('codicon')) {
         return