EditScreen: Support ":w" in CodeMirror's Vim keymap

The Vim keymap can make use of a custom save command defined
in the CodeMirror.commands object. Adding this custom command
allows EditScreen to perform the actual save action instead of
showing an obscure TypeError.

Change-Id: I5bf01d520ed9a299685736368f43847f9bd33b63
This commit is contained in:
Michael Zhou
2016-03-25 17:54:16 -04:00
parent cced99ae2d
commit 561534b294
2 changed files with 19 additions and 0 deletions

View File

@@ -71,6 +71,7 @@ import com.google.gwtexpui.safehtml.client.SafeHtml;
import net.codemirror.lib.CodeMirror;
import net.codemirror.lib.CodeMirror.ChangesHandler;
import net.codemirror.lib.CodeMirror.CommandRunner;
import net.codemirror.lib.Configuration;
import net.codemirror.lib.KeyMap;
import net.codemirror.lib.Pos;
@@ -435,6 +436,13 @@ public class EditScreen extends Screen {
.set("keyMap", prefs.keyMapType().name().toLowerCase())
.set("theme", prefs.theme().name().toLowerCase())
.set("mode", mode != null ? mode.mode() : null));
CodeMirror.addCommand("save", new CommandRunner() {
@Override
public void run(CodeMirror instance) {
save().run();
}
});
}
private void renderLinks(EditFileInfo editInfo,