From e6eb3554d69e3d7a7df25b7ac396a8448d118db5 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 15 Oct 2019 18:00:54 +0200 Subject: [PATCH] Make autoCloseBrackets configurable per user --- www/common/sframe-common-codemirror.js | 7 ++++-- www/settings/inner.js | 30 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/www/common/sframe-common-codemirror.js b/www/common/sframe-common-codemirror.js index 3f312aa68..d16bea97a 100644 --- a/www/common/sframe-common-codemirror.js +++ b/www/common/sframe-common-codemirror.js @@ -379,13 +379,14 @@ define([ }; exp.mkIndentSettings = function (metadataMgr) { - var setIndentation = function (units, useTabs, fontSize, spellcheck) { + var setIndentation = function (units, useTabs, fontSize, spellcheck, brackets) { if (typeof(units) !== 'number') { return; } var doc = editor.getDoc(); editor.setOption('indentUnit', units); editor.setOption('tabSize', units); editor.setOption('indentWithTabs', useTabs); editor.setOption('spellcheck', spellcheck); + editor.setOption('autoCloseBrackets', brackets); editor.setOption("extraKeys", { Tab: function() { if (doc.somethingSelected()) { @@ -415,11 +416,13 @@ define([ var useTabs = data[useTabsKey]; var fontSize = data[fontKey]; var spellcheck = data[spellcheckKey]; + var brackets = data.brackets; setIndentation( typeof(indentUnit) === 'number'? indentUnit : 2, typeof(useTabs) === 'boolean'? useTabs : false, typeof(fontSize) === 'number' ? fontSize : 12, - typeof(spellcheck) === 'boolean' ? spellcheck : false); + typeof(spellcheck) === 'boolean' ? spellcheck : false, + typeof(brackets) === 'boolean' ? brackets : true); }; metadataMgr.onChangeLazy(updateIndentSettings); updateIndentSettings(); diff --git a/www/settings/inner.js b/www/settings/inner.js index 416f99bb8..37693d3c9 100644 --- a/www/settings/inner.js +++ b/www/settings/inner.js @@ -85,6 +85,7 @@ define([ 'code': [ 'cp-settings-code-indent-unit', 'cp-settings-code-indent-type', + 'cp-settings-code-brackets', 'cp-settings-code-font-size', 'cp-settings-code-spellcheck', ], @@ -1445,6 +1446,35 @@ define([ return $div; }; + create['code-brackets'] = function () { + var key = 'brackets'; + + var $div = $('
', { + 'class': 'cp-settings-code-brackets cp-sidebarlayout-element' + }); + $('