@@ -19953,6 +19953,19 @@ define("editor/Editor", function (require, exports, module) {
1995319953 return $(this.getRootElement());
1995419954 }
1995519955 });
19956+
19957+ const $cmElement = this.$el;
19958+ $cmElement[0].addEventListener("wheel", (event) => {
19959+ const $editor = $cmElement.find(".CodeMirror-scroll");
19960+ // we need to slow down the scroll by the factor of line height. else the scrolling is too fast.
19961+ // this became a problem after we added the custom line height feature causing jumping scrolls esp in safari
19962+ // and mac if we dont do this scroll scaling.
19963+ const lineHeight = parseFloat(getComputedStyle($editor[0]).lineHeight);
19964+ const scrollDelta = event.deltaY;
19965+ const defaultHeight = 14, scrollScaleFactor = lineHeight/defaultHeight;
19966+ $editor[0].scrollTop += (scrollDelta/scrollScaleFactor);
19967+ event.preventDefault();
19968+ });
1995619969 }
1995719970
1995819971 EventDispatcher.makeEventDispatcher(Editor.prototype);
@@ -43759,7 +43772,8 @@ define("extensionsIntegrated/indentGuides/main", function (require, exports, mod
4375943772
4376043773 const COMMAND_NAME = Strings.CMD_TOGGLE_INDENT_GUIDES,
4376143774 COMMAND_ID = Commands.TOGGLE_INDENT_GUIDES,
43762- GUIDE_CLASS = "phcode-indent-guides";
43775+ GUIDE_CLASS = "phcode-indent-guides",
43776+ GUIDE_CLASS_NONE = "phcode-indent-guides-none";
4376343777
4376443778 const PREFERENCES_EDITOR_INDENT_GUIDES = "editor.indentGuides",
4376543779 PREFERENCES_EDITOR_INDENT_HIDE_FIRST = "editor.indentHideFirst";
@@ -43777,69 +43791,89 @@ define("extensionsIntegrated/indentGuides/main", function (require, exports, mod
4377743791 });
4377843792
4377943793 // CodeMirror overlay code
43780- const indentGuidesOverlay = {
43781- token: function (stream, _state) {
43782- let char = "",
43783- colNum = 0,
43784- spaceUnits = 0,
43785- isTabStart = false;
43786-
43787- char = stream.next();
43788- colNum = stream.column();
43789-
43790- // Check for "hide first guide" preference
43791- if ((hideFirst) && (colNum === 0)) {
43792- return null;
43793- }
43794+ function _createOverlayObject(spaceUnits) {
43795+ return {
43796+ _spaceUnits: spaceUnits,
43797+ _cmRefreshPending: false,
43798+ token: function (stream, _state) {
43799+ let char = "",
43800+ colNum = 0,
43801+ isTabStart = false;
43802+
43803+ char = stream.next();
43804+ colNum = stream.column();
43805+
43806+ // Check for "hide first guide" preference
43807+ if ((hideFirst) && (colNum === 0)) {
43808+ return null;
43809+ }
4379443810
43795- if (char === "\t") {
43796- return GUIDE_CLASS;
43797- }
43811+ if (char === "\t") {
43812+ return enabled? GUIDE_CLASS : GUIDE_CLASS_NONE ;
43813+ }
4379843814
43799- if (char !== " ") {
43800- stream.skipToEnd();
43801- return null;
43802- }
43815+ if (char !== " ") {
43816+ stream.skipToEnd();
43817+ return null;
43818+ }
4380343819
43804- spaceUnits = Editor.getSpaceUnits();
43805- isTabStart = (colNum % spaceUnits) ? false : true;
43820+ isTabStart = (colNum % this._spaceUnits) === 0 ? true : false;
4380643821
43807- if ((char === " ") && (isTabStart)) {
43808- return GUIDE_CLASS;
43809- }
43810- return null;
43811- },
43812- flattenSpans: false
43813- };
43822+ if ((char === " ") && (isTabStart)) {
43823+ return enabled? GUIDE_CLASS : GUIDE_CLASS_NONE;
43824+ }
43825+ return null;
43826+ },
43827+ flattenSpans: false
43828+ };
43829+ }
4381443830
4381543831 function applyPreferences() {
4381643832 enabled = PreferencesManager.get(PREFERENCES_EDITOR_INDENT_GUIDES);
4381743833 hideFirst = PreferencesManager.get(PREFERENCES_EDITOR_INDENT_HIDE_FIRST);
4381843834 }
4381943835
4382043836 function updateUI() {
43821- const editor = EditorManager.getActiveEditor(),
43822- cm = editor ? editor._codeMirror : null;
43823-
43824- // Update CodeMirror overlay if editor is available
43825- if (cm) {
43826- if(editor._overlayPresent){
43827- if(!enabled){
43828- cm.removeOverlay(indentGuidesOverlay);
43829- editor._overlayPresent = false;
43830- cm.refresh();
43837+ const editor = EditorManager.getActiveEditor();
43838+ if(!editor || !editor._codeMirror) {
43839+ return;
43840+ }
43841+ const cm = editor._codeMirror;
43842+ if(!editor.__indentGuidesOverlay) {
43843+ editor.__indentGuidesOverlay = _createOverlayObject(Editor.getSpaceUnits(editor.document.file.fullPath));
43844+ }
43845+ function _reRenderOverlay() {
43846+ cm.removeOverlay(editor.__indentGuidesOverlay);
43847+ cm.addOverlay(editor.__indentGuidesOverlay);
43848+ }
43849+ editor.off(Editor.EVENT_OPTION_CHANGE+".indentGuide");
43850+ editor.on(Editor.EVENT_OPTION_CHANGE+".indentGuide", ()=>{
43851+ const newSpaceUnits = Editor.getSpaceUnits(editor.document.file.fullPath);
43852+ if(newSpaceUnits !== editor.__indentGuidesOverlay._spaceUnits){
43853+ editor.__indentGuidesOverlay._spaceUnits = newSpaceUnits;
43854+ if(EditorManager.getActiveEditor() === editor){
43855+ console.log("space units changed, refreshing indent guides for",
43856+ newSpaceUnits, editor.document.file.fullPath);
43857+ _reRenderOverlay();
4383143858 }
43832- } else if(enabled){
43833- cm.removeOverlay(indentGuidesOverlay);
43834- cm.addOverlay(indentGuidesOverlay);
43835- editor._overlayPresent = true;
43836- cm.refresh();
4383743859 }
43838- }
43860+ });
4383943861
43840- // Update menu
43841- CommandManager.get(COMMAND_ID)
43842- .setChecked(enabled);
43862+ let shouldRerender = false;
43863+ if(!cm.__indentGuidesOverlayAttached){
43864+ cm.addOverlay(editor.__indentGuidesOverlay);
43865+ cm.__indentGuidesOverlayAttached = editor.__indentGuidesOverlay;
43866+ cm.__overlayEnabled = enabled;
43867+ } else if(cm.__indentGuidesOverlayAttached &&
43868+ cm.__indentGuidesOverlayAttached !== editor.__indentGuidesOverlay) {
43869+ cm.removeOverlay(cm.__indentGuidesOverlayAttached);
43870+ cm.addOverlay(editor.__indentGuidesOverlay);
43871+ cm.__overlayEnabled = enabled;
43872+ } else if (shouldRerender || cm.__overlayEnabled !== enabled) {
43873+ cm.__overlayEnabled = enabled;
43874+ _reRenderOverlay();
43875+ console.log("Refreshing indent guides");
43876+ }
4384343877 }
4384443878
4384543879 function handleToggleGuides() {
@@ -43850,6 +43884,8 @@ define("extensionsIntegrated/indentGuides/main", function (require, exports, mod
4385043884 function preferenceChanged() {
4385143885 applyPreferences();
4385243886 updateUI();
43887+ CommandManager.get(COMMAND_ID)
43888+ .setChecked(enabled);
4385343889 }
4385443890
4385543891 // Initialize extension
@@ -91883,6 +91919,7 @@ define("nls/root/strings", {
9188391919 "USE_THEME_SCROLLBARS": "Use Theme Scrollbars",
9188491920 "FONT_SIZE": "Font Size",
9188591921 "FONT_FAMILY": "Font Family",
91922+ "FONT_LINE_HEIGHT": "Line Height",
9188691923 "THEMES_SETTINGS": "Themes Settings",
9188791924 "THEMES_ERROR": "Themes Error",
9188891925 "THEMES_ERROR_CANNOT_APPLY": "Could not apply theme due to an error.",
@@ -92249,6 +92286,7 @@ define("nls/root/strings", {
9224992286 "DESCRIPTION_NUMBER_QUICK_VIEW": "true to show Quick View on hover over numbers in editor",
9225092287 "DESCRIPTION_THEME": "Select a {APP_NAME} theme",
9225192288 "DESCRIPTION_USE_THEME_SCROLLBARS": "true to allow custom scroll bars",
92289+ "DESCRIPTION_EDITOR_LINE_HEIGHT": "Adjust the vertical spacing between lines of code in the editor. Choose a value between 1 and 3, default is 1.5",
9225292290 "DESCRIPTION_LINTING_COLLAPSED": "true to collapse linting panel",
9225392291 "DESCRIPTION_FONT_FAMILY": "Change font family",
9225492292 "DESCRIPTION_DESKTOP_ZOOM_SCALE": "Choose a zoom scale factor ranging from 0.1 (for a more compact view) to 2 (for a larger, more magnified view). Available in desktop apps only",
@@ -156792,6 +156830,21 @@ define("view/ThemeSettings", function (require, exports, module) {
156792156830 <input type="text" data-target="fontFamily" value="{{settings.fontFamily}}">
156793156831 </div>
156794156832 </div>
156833+
156834+ <div class="control-group">
156835+ <label class="control-label">{{Strings.FONT_LINE_HEIGHT}}:</label>
156836+ <div class="controls line-height-slider">
156837+ <input
156838+ type="range"
156839+ min="1"
156840+ max="3"
156841+ step="0.1"
156842+ value="{{settings.editorLineHeight}}"
156843+ class="form-range fontLineHeightSlider"
156844+ data-target="editorLineHeight">
156845+ <span class="fontLineHeightValue">{{settings.editorLineHeight}}</span>
156846+ </div>
156847+ </div>
156795156848 </form>
156796156849 </div>
156797156850 <div class="modal-footer">
@@ -156820,7 +156873,8 @@ define("view/ThemeSettings", function (require, exports, module) {
156820156873 themeScrollbars: true,
156821156874 theme: SYSTEM_DEFAULT_THEME,
156822156875 lightTheme: "light-theme",
156823- darkTheme: "dark-theme"
156876+ darkTheme: "dark-theme",
156877+ editorLineHeight: 1.5
156824156878 };
156825156879
156826156880
@@ -156903,6 +156957,12 @@ define("view/ThemeSettings", function (require, exports, module) {
156903156957 var targetValue = $(this).val();
156904156958 newSettings["fontFamily"] = targetValue;
156905156959 })
156960+ .on("input", ".fontLineHeightSlider", function () {
156961+ const targetValue = $(this).val();
156962+ $template.find(".fontLineHeightValue").text(targetValue);
156963+ newSettings["editorLineHeight"] = targetValue;
156964+ prefs.set("editorLineHeight", targetValue + "");
156965+ })
156906156966 .on("change", "select", function () {
156907156967 var $target = $(":selected", this);
156908156968 var attr = $target.attr("data-target");
@@ -156933,6 +156993,7 @@ define("view/ThemeSettings", function (require, exports, module) {
156933156993 } else if (id === "cancel") {
156934156994 // Make sure we revert any changes to theme selection
156935156995 prefs.set("theme", currentSettings.theme);
156996+ prefs.set("editorLineHeight", currentSettings.editorLineHeight);
156936156997 }
156937156998 });
156938156999 $template
@@ -156967,6 +157028,15 @@ define("view/ThemeSettings", function (require, exports, module) {
156967157028 prefs.definePreference("themeScrollbars", "boolean", DEFAULTS.themeScrollbars, {
156968157029 description: Strings.DESCRIPTION_USE_THEME_SCROLLBARS
156969157030 });
157031+ prefs.definePreference("editorLineHeight", "number", DEFAULTS.editorLineHeight, {
157032+ description: Strings.DESCRIPTION_EDITOR_LINE_HEIGHT
157033+ });
157034+
157035+ prefs.on("change", "editorLineHeight", function () {
157036+ const lineHeight = prefs.get("editorLineHeight") + "";
157037+ const $phoenixMain = $('#Phoenix-Main');
157038+ $phoenixMain[0].style.setProperty('--editor-line-height', lineHeight);
157039+ });
156970157040
156971157041 exports.DEFAULTS = DEFAULTS;
156972157042 exports._setThemes = setThemes;
0 commit comments