@@ -8274,6 +8274,7 @@ define("command/Commands", function (require, exports, module) {
82748274 exports.TOGGLE_ACTIVE_LINE = "view.toggleActiveLine"; // EditorOptionHandlers.js _getToggler()
82758275 exports.TOGGLE_WORD_WRAP = "view.toggleWordWrap"; // EditorOptionHandlers.js _getToggler()
82768276 exports.TOGGLE_RULERS = "view.toggleRulers"; // EditorOptionHandlers.js
8277+ exports.TOGGLE_INDENT_GUIDES = "view.toggleIndentGuides"; // integrated extension indentGuides
82778278 exports.TOGGLE_SEARCH_AUTOHIDE = "view.toggleSearchAutoHide"; // EditorOptionHandlers.js _getToggler()
82788279
82798280 exports.CMD_OPEN = "cmd.open";
@@ -42879,6 +42880,155 @@ define("extensionsIntegrated/icons/main", function (require, exports, module) {
4287942880 *
4288042881 */
4288142882
42883+ // Adapted from https://github.com/lkcampbell/brackets-indent-guides by Lance Campbell.
42884+
42885+ /*jslint vars: true, plusplus: true, devel: true, regexp: true, nomen: true, indent: 4, maxerr: 50 */
42886+
42887+ define("extensionsIntegrated/indentGuides/main", function (require, exports, module) {
42888+
42889+ const PreferencesManager = require("preferences/PreferencesManager"),
42890+ Menus = require("command/Menus"),
42891+ Editor = require("editor/Editor").Editor,
42892+ EditorManager = require("editor/EditorManager"),
42893+ AppInit = require("utils/AppInit"),
42894+ Commands = require("command/Commands"),
42895+ CommandManager = require("command/CommandManager"),
42896+ MainViewManager = require("view/MainViewManager"),
42897+ Strings = require("strings");
42898+
42899+ const COMMAND_NAME = Strings.CMD_TOGGLE_INDENT_GUIDES,
42900+ COMMAND_ID = Commands.TOGGLE_INDENT_GUIDES,
42901+ GUIDE_CLASS = "phcode-indent-guides";
42902+
42903+ const PREFERENCES_EDITOR_INDENT_GUIDES = "editor.indentGuides",
42904+ PREFERENCES_EDITOR_INDENT_HIDE_FIRST = "editor.indentHideFirst";
42905+
42906+ // Define extension preferences
42907+ let enabled = true,
42908+ hideFirst = false;
42909+
42910+ PreferencesManager.definePreference(PREFERENCES_EDITOR_INDENT_GUIDES, "boolean", enabled, {
42911+ description: Strings.DESCRIPTION_INDENT_GUIDES_ENABLED
42912+ });
42913+
42914+ PreferencesManager.definePreference(PREFERENCES_EDITOR_INDENT_HIDE_FIRST, "boolean", hideFirst, {
42915+ description: Strings.DESCRIPTION_HIDE_FIRST
42916+ });
42917+
42918+ // CodeMirror overlay code
42919+ const indentGuidesOverlay = {
42920+ token: function (stream, _state) {
42921+ let char = "",
42922+ colNum = 0,
42923+ spaceUnits = 0,
42924+ isTabStart = false;
42925+
42926+ char = stream.next();
42927+ colNum = stream.column();
42928+
42929+ // Check for "hide first guide" preference
42930+ if ((hideFirst) && (colNum === 0)) {
42931+ return null;
42932+ }
42933+
42934+ if (char === "\t") {
42935+ return GUIDE_CLASS;
42936+ }
42937+
42938+ if (char !== " ") {
42939+ stream.skipToEnd();
42940+ return null;
42941+ }
42942+
42943+ spaceUnits = Editor.getSpaceUnits();
42944+ isTabStart = (colNum % spaceUnits) ? false : true;
42945+
42946+ if ((char === " ") && (isTabStart)) {
42947+ return GUIDE_CLASS;
42948+ }
42949+ return null;
42950+ },
42951+ flattenSpans: false
42952+ };
42953+
42954+ function applyPreferences() {
42955+ enabled = PreferencesManager.get(PREFERENCES_EDITOR_INDENT_GUIDES);
42956+ hideFirst = PreferencesManager.get(PREFERENCES_EDITOR_INDENT_HIDE_FIRST);
42957+ }
42958+
42959+ function updateUI() {
42960+ const editor = EditorManager.getActiveEditor(),
42961+ cm = editor ? editor._codeMirror : null;
42962+
42963+ // Update CodeMirror overlay if editor is available
42964+ if (cm) {
42965+ if(editor._overlayPresent){
42966+ if(!enabled){
42967+ cm.removeOverlay(indentGuidesOverlay);
42968+ editor._overlayPresent = false;
42969+ cm.refresh();
42970+ }
42971+ } else if(enabled){
42972+ cm.removeOverlay(indentGuidesOverlay);
42973+ cm.addOverlay(indentGuidesOverlay);
42974+ editor._overlayPresent = true;
42975+ cm.refresh();
42976+ }
42977+ }
42978+
42979+ // Update menu
42980+ CommandManager.get(COMMAND_ID)
42981+ .setChecked(enabled);
42982+ }
42983+
42984+ function handleToggleGuides() {
42985+ enabled = !enabled;
42986+ PreferencesManager.set(PREFERENCES_EDITOR_INDENT_GUIDES, enabled);
42987+ }
42988+
42989+ function preferenceChanged() {
42990+ applyPreferences();
42991+ updateUI();
42992+ }
42993+
42994+ // Initialize extension
42995+ AppInit.appReady(function () {
42996+ // Register command and add to menu
42997+ CommandManager.register(COMMAND_NAME, COMMAND_ID, handleToggleGuides);
42998+ Menus.getMenu(Menus.AppMenuBar.VIEW_MENU)
42999+ .addMenuItem(COMMAND_ID, "", Menus.AFTER, Commands.TOGGLE_RULERS);
43000+
43001+ // Set up event listeners
43002+ PreferencesManager.on("change", PREFERENCES_EDITOR_INDENT_GUIDES, preferenceChanged);
43003+ PreferencesManager.on("change", PREFERENCES_EDITOR_INDENT_HIDE_FIRST, preferenceChanged);
43004+
43005+ MainViewManager.on("currentFileChange", updateUI);
43006+ EditorManager.on("activeEditorChange", updateUI);
43007+
43008+ // Apply preferences and draw indent guides
43009+ preferenceChanged();
43010+ });
43011+ });
43012+ /*
43013+ * GNU AGPL-3.0 License
43014+ *
43015+ * Copyright (c) 2021 - present core.ai . All rights reserved.
43016+ *
43017+ * This program is free software: you can redistribute it and/or modify it
43018+ * under the terms of the GNU Affero General Public License as published by
43019+ * the Free Software Foundation, either version 3 of the License, or
43020+ * (at your option) any later version.
43021+ *
43022+ * This program is distributed in the hope that it will be useful, but WITHOUT
43023+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
43024+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
43025+ * for more details.
43026+ *
43027+ * You should have received a copy of the GNU Affero General Public License
43028+ * along with this program. If not, see https://opensource.org/licenses/AGPL-3.0.
43029+ *
43030+ */
43031+
4288243032
4288343033/**
4288443034 * Integrated extensions are special core extensions directly loaded through this file.
@@ -42902,6 +43052,7 @@ define("extensionsIntegrated/loader", function (require, exports, module) {
4290243052 require("./DisplayShortcuts/main");
4290343053 require("./appUpdater/main");
4290443054 require("./HtmlTagSyncEdit/main");
43055+ require("./indentGuides/main");
4290543056});
4290643057
4290743058/*
@@ -90106,6 +90257,7 @@ define("nls/root/strings", {
9010690257 "CMD_THEMES": "Themes\u2026",
9010790258 "CMD_TOGGLE_SEARCH_AUTOHIDE": "Automatically close search",
9010890259 "CMD_TOGGLE_RULERS": "Rulers",
90260+ "CMD_TOGGLE_INDENT_GUIDES": "Indent Guide Lines",
9010990261 "CMD_KEYBOARD_NAV_OVERLAY": "Visual Command Palette",
9011090262
9011190263 // Navigate menu commands
@@ -90778,7 +90930,10 @@ define("nls/root/strings", {
9077890930 "BEAUTIFY_OPTION_BRACKET_SAME_LINE": "Put the > of a multi-line HTML (HTML, JSX, Vue, Angular) element at the end of the last line instead of being alone on the next line (does not apply to self closing elements)",
9077990931 "BEAUTIFY_OPTION_SINGLE_ATTRIBUTE_PER_LINE": "Enforce single attribute per line in HTML, Vue and JSX",
9078090932 "BEAUTIFY_OPTION_PROSE_WRAP": "Wrap prose if it exceeds the print width in markdown files",
90781- "BEAUTIFY_OPTION_PRINT_TRAILING_COMMAS": "Print trailing commas wherever possible in multi-line comma-separated syntactic structures"
90933+ "BEAUTIFY_OPTION_PRINT_TRAILING_COMMAS": "Print trailing commas wherever possible in multi-line comma-separated syntactic structures",
90934+ // indent guides extension
90935+ "DESCRIPTION_INDENT_GUIDES_ENABLED": "true to show indent guide lines, else false.",
90936+ "DESCRIPTION_HIDE_FIRST": "true to show the first Indent Guide line else false."
9078290937});
9078390938
9078490939/*
@@ -123076,7 +123231,6 @@ define("preferences/PreferencesManager", function (require, exports, module) {
123076123231 * GNU AGPL-3.0 License
123077123232 *
123078123233 * Copyright (c) 2021 - present core.ai . All rights reserved.
123079- * Original work Copyright (c) 2012 - 2021 Adobe Systems Incorporated. All rights reserved.
123080123234 *
123081123235 * This program is free software: you can redistribute it and/or modify it
123082123236 * under the terms of the GNU Affero General Public License as published by
0 commit comments