Jelajahi Sumber

Merge pull request #12672 from overleaf/ae-emacs-compile-keydown

[cm6] Stop propagation of Ctrl-s when Emacs keybindings are enabled

GitOrigin-RevId: 32bebefb583ad813931af221cce7498d40fdbaf1
Mathias Jakobsen 3 tahun lalu
induk
melakukan
81a8fa2ce3

+ 11 - 1
services/web/frontend/js/features/source-editor/extensions/keybindings.ts

@@ -8,6 +8,7 @@ import {
 import { EmacsHandler } from '@replit/codemirror-emacs'
 import { CodeMirror } from '@replit/codemirror-vim'
 import { foldCode, toggleFold, unfoldCode } from '@codemirror/language'
+import { EditorView } from '@codemirror/view'
 import {
   cursorToBeginningOfVisualLine,
   cursorToEndOfVisualLine,
@@ -174,7 +175,16 @@ const options = [
     load: () =>
       import('@replit/codemirror-emacs').then(m => {
         customiseEmacsOnce()
-        return m.emacs()
+        return [
+          m.emacs(),
+          EditorView.domEventHandlers({
+            keydown(event) {
+              if (event.ctrlKey && event.key === 's') {
+                event.stopPropagation()
+              }
+            },
+          }),
+        ]
       }),
   },
 ]