From 0e93c51c371527b93bb4b7fae14ce500942eb9c6 2014-11-20 19:52:36
From: Thomas Kluyver <takowl@gmail.com>
Date: 2014-11-20 19:52:36
Subject: [PATCH] Better way of saving through CodeMirror

This should support whatever keyboard shortcuts are configured for the
'save' command.

---

diff --git a/IPython/html/static/texteditor/js/editor.js b/IPython/html/static/texteditor/js/editor.js
index 6861819..48e2e88 100644
--- a/IPython/html/static/texteditor/js/editor.js
+++ b/IPython/html/static/texteditor/js/editor.js
@@ -21,6 +21,11 @@ function($,
         
         this.codemirror = CodeMirror($(this.selector)[0]);
         
+        // It appears we have to set commands on the CodeMirror class, not the
+        // instance. I'd like to be wrong, but since there should only be one CM
+        // instance on the page, this is good enough for now.
+        CodeMirror.commands.save = $.proxy(this.save, this);
+        
         this.save_enabled = false;
     };
     
@@ -46,9 +51,6 @@ function($,
                 that.save_enabled = false;
             }
         );
-        cm.setOption("extraKeys", {
-            "Ctrl-S": $.proxy(this.save, this),
-        });
     };
 
     Editor.prototype.save = function() {