Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/web/js/beforePyret.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ $(function() {
console.log("Using keymap: ", CodeMirror.keyMap.default, "macDefault: ", CodeMirror.keyMap.macDefault, "mac: ", mac);
const modifier = mac ? "Cmd" : "Ctrl";

var cmOptions = {
extraKeys: CodeMirror.normalizeKeyMap({
const extraKeys = {
"Shift-Enter": function(cm) { runFun(cm.getValue()); },
"Shift-Ctrl-Enter": function(cm) { runFun(cm.getValue()); },
"Tab": "indentAuto",
Expand All @@ -211,7 +210,21 @@ $(function() {
"Ctrl-Right": "goForwardToken",
[`${modifier}-F`]: "findPersistent",
[`${modifier}-/`]: "toggleComment",
}),
};
if(window.PYRET_IN_VSCODE) {
// Disable undo and redo in vscode, since they mess with the host editor's undo/redo stack
// Oddly, it doesn't seem to work to add these to extraKeys; I have to
// override them in the default keymap
CodeMirror.keyMap.default[`${modifier}-Z`] = false;
CodeMirror.keyMap.default[`Shift-${modifier}-Z`] = false;
CodeMirror.keyMap.default[`${modifier}-Y`] = false;
// Ctrl-U is Undo within a range
CodeMirror.keyMap.default[`${modifier}-U`] = false;
}

var cmOptions = {
keyMap: 'default',
extraKeys: CodeMirror.normalizeKeyMap(extraKeys),
indentUnit: 2,
tabSize: 2,
viewportMargin: Infinity,
Expand Down Expand Up @@ -1469,6 +1482,7 @@ $(function() {
let initialState = params["get"]["initialState"];

window.PYRET_IS_EMBEDDED = false;
window.PYRET_IN_VSCODE = false;
if (typeof acquireVsCodeApi === "function") {
window.MESSAGES = makeEvents({
CPO: CPO,
Expand All @@ -1477,6 +1491,7 @@ $(function() {
initialState
});
window.PYRET_IS_EMBEDDED = true;
window.PYRET_IN_VSCODE = true;
}
else if((window.parent && (window.parent !== window))) {
window.MESSAGES = makeEvents({ CPO: CPO, sendPort: window.parent, receivePort: window, initialState });
Expand Down