Skip to content

Commit

Permalink
CodeEditor: fix ctrl-s not saving when switching between code editiors
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoVgr committed Dec 19, 2024
1 parent f933ed9 commit 33cc5b1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions hide/comp/CodeEditor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ class CodeEditor extends Component {
});
var model = editor.getModel();
(model : Dynamic).__comp__ = this;
errorMessage = new Element('<div class="codeErrorMessage"></div>').appendTo(root).hide();
model.updateOptions({ insertSpaces:false, trimAutoWhitespace:true });
editor.onDidChangeModelContent(function() onChanged());
editor.onDidBlurEditorText(function() if( saveOnBlur ) onSave());
editor.addCommand(monaco.KeyCode.KEY_S | monaco.KeyMod.CtrlCmd, function() { saveBind(); });
errorMessage = new Element('<div class="codeErrorMessage"></div>').appendTo(root).hide();

// This is needed because from monaco editor v0.31.1 to current version, commands added are global and not per editor (this is a bug)
editor.onDidFocusEditorText(function() {
editor.addCommand(monaco.KeyCode.KEY_S | monaco.KeyMod.CtrlCmd, function() {
saveBind();
});
});
}

function saveBind() {
Expand Down

0 comments on commit 33cc5b1

Please sign in to comment.