mirror of
https://github.com/adobe/brackets.git
synced 2024-11-20 01:42:55 +01:00
Revert "Ensures fold-gutter is always inserted after the line-number gutter (if it exists)"
This commit is contained in:
parent
57278636e2
commit
812111e7c4
@ -20,7 +20,6 @@
|
|||||||
"clearTimeout",
|
"clearTimeout",
|
||||||
|
|
||||||
"ArrayBuffer",
|
"ArrayBuffer",
|
||||||
"MutationObserver",
|
|
||||||
"XMLHttpRequest",
|
"XMLHttpRequest",
|
||||||
"Uint32Array",
|
"Uint32Array",
|
||||||
"WebSocket"
|
"WebSocket"
|
||||||
|
@ -61,7 +61,6 @@
|
|||||||
"clearTimeout": false,
|
"clearTimeout": false,
|
||||||
|
|
||||||
"ArrayBuffer": false,
|
"ArrayBuffer": false,
|
||||||
"MutationObserver": false,
|
|
||||||
"XMLHttpRequest": false,
|
"XMLHttpRequest": false,
|
||||||
"Uint32Array": false,
|
"Uint32Array": false,
|
||||||
"WebSocket": false
|
"WebSocket": false
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
* @author Patrick Oladimeji
|
* @author Patrick Oladimeji
|
||||||
* @date 10/24/13 9:35:26 AM
|
* @date 10/24/13 9:35:26 AM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define(function (require, exports, module) {
|
define(function (require, exports, module) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
@ -52,12 +53,7 @@ define(function (require, exports, module) {
|
|||||||
collapseAllKey = "Alt-1",
|
collapseAllKey = "Alt-1",
|
||||||
expandAllKey = "Shift-Alt-1",
|
expandAllKey = "Shift-Alt-1",
|
||||||
collapseAllKeyMac = "Cmd-1",
|
collapseAllKeyMac = "Cmd-1",
|
||||||
expandAllKeyMac = "Cmd-Shift-1",
|
expandAllKeyMac = "Cmd-Shift-1";
|
||||||
SAVE_FOLD_STATES = "saveFoldStates",
|
|
||||||
HIDE_UNTIL_MOUSE_OVER = "hideUntilMouseover",
|
|
||||||
MAKE_SELECTION_FOLDABLE = "makeSelectionFoldable",
|
|
||||||
ALWAYS_USE_INDENT_FOLD = "alwaysUseIndentFold",
|
|
||||||
LINE_NUMBER_GUTTER = "CodeMirror-linenumbers";
|
|
||||||
|
|
||||||
ExtensionUtils.loadStyleSheet(module, "main.less");
|
ExtensionUtils.loadStyleSheet(module, "main.less");
|
||||||
|
|
||||||
@ -74,10 +70,10 @@ define(function (require, exports, module) {
|
|||||||
indentFold = require("foldhelpers/indentFold"),
|
indentFold = require("foldhelpers/indentFold"),
|
||||||
selectionFold = require("foldhelpers/foldSelected");
|
selectionFold = require("foldhelpers/foldSelected");
|
||||||
|
|
||||||
|
|
||||||
/** Set to true when init() has run; set back to false after deinit() has run */
|
/** Set to true when init() has run; set back to false after deinit() has run */
|
||||||
var _isInitialized = false,
|
var _isInitialized = false;
|
||||||
gutterObservers = {};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restores the linefolds in the editor using values fetched from the preference store
|
* Restores the linefolds in the editor using values fetched from the preference store
|
||||||
* Checks the document to ensure that changes have not been made (e.g., in a different editor)
|
* Checks the document to ensure that changes have not been made (e.g., in a different editor)
|
||||||
@ -116,7 +112,7 @@ define(function (require, exports, module) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var saveFolds = prefs.getSetting(SAVE_FOLD_STATES);
|
var saveFolds = prefs.getSetting("saveFoldStates");
|
||||||
if (!editor || !saveFolds) {
|
if (!editor || !saveFolds) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -151,7 +147,7 @@ define(function (require, exports, module) {
|
|||||||
* @param {Editor} editor the editor whose line folds should be saved
|
* @param {Editor} editor the editor whose line folds should be saved
|
||||||
*/
|
*/
|
||||||
function saveLineFolds(editor) {
|
function saveLineFolds(editor) {
|
||||||
var saveFolds = prefs.getSetting(SAVE_FOLD_STATES);
|
var saveFolds = prefs.getSetting("saveFoldStates");
|
||||||
if (!editor || !saveFolds) {
|
if (!editor || !saveFolds) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -267,7 +263,6 @@ define(function (require, exports, module) {
|
|||||||
*/
|
*/
|
||||||
function createGutter(editor) {
|
function createGutter(editor) {
|
||||||
var cm = editor._codeMirror;
|
var cm = editor._codeMirror;
|
||||||
var rootElement = editor.getRootElement();
|
|
||||||
var path = editor.document.file.fullPath, _lineFolds = prefs.getFolds(path);
|
var path = editor.document.file.fullPath, _lineFolds = prefs.getFolds(path);
|
||||||
_lineFolds = _lineFolds || {};
|
_lineFolds = _lineFolds || {};
|
||||||
cm._lineFolds = _lineFolds;
|
cm._lineFolds = _lineFolds;
|
||||||
@ -275,12 +270,9 @@ define(function (require, exports, module) {
|
|||||||
|
|
||||||
// Reuse any existing fold gutter
|
// Reuse any existing fold gutter
|
||||||
if (gutters.indexOf(GUTTER_NAME) < 0) {
|
if (gutters.indexOf(GUTTER_NAME) < 0) {
|
||||||
var lineNumberIndex = gutters.indexOf(LINE_NUMBER_GUTTER);
|
var lnIndex = gutters.indexOf("CodeMirror-linenumbers");
|
||||||
if (lineNumberIndex < 0) {
|
$(editor.getRootElement()).addClass("folding-enabled");
|
||||||
$(rootElement).addClass("linenumber-disabled");
|
gutters.splice(lnIndex + 1, 0, GUTTER_NAME);
|
||||||
}
|
|
||||||
$(rootElement).addClass("folding-enabled");
|
|
||||||
gutters.splice(lineNumberIndex + 1, 0, GUTTER_NAME);
|
|
||||||
cm.setOption("gutters", gutters);
|
cm.setOption("gutters", gutters);
|
||||||
cm.refresh(); // force recomputing gutter width - .folding-enabled class affects linenumbers gutter which has existing cached width
|
cm.refresh(); // force recomputing gutter width - .folding-enabled class affects linenumbers gutter which has existing cached width
|
||||||
}
|
}
|
||||||
@ -288,17 +280,17 @@ define(function (require, exports, module) {
|
|||||||
|
|
||||||
$(cm.getGutterElement()).on({
|
$(cm.getGutterElement()).on({
|
||||||
mouseenter: function () {
|
mouseenter: function () {
|
||||||
if (prefs.getSetting(HIDE_UNTIL_MOUSE_OVER)) {
|
if (prefs.getSetting("hideUntilMouseover")) {
|
||||||
foldGutter.updateInViewport(cm);
|
foldGutter.updateInViewport(cm);
|
||||||
} else {
|
} else {
|
||||||
$(rootElement).addClass("over-gutter");
|
$(editor.getRootElement()).addClass("over-gutter");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mouseleave: function () {
|
mouseleave: function () {
|
||||||
if (prefs.getSetting(HIDE_UNTIL_MOUSE_OVER)) {
|
if (prefs.getSetting("hideUntilMouseover")) {
|
||||||
foldGutter.clearGutter(cm);
|
foldGutter.clearGutter(cm);
|
||||||
} else {
|
} else {
|
||||||
$(rootElement).removeClass("over-gutter");
|
$(editor.getRootElement()).removeClass("over-gutter");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -312,12 +304,10 @@ define(function (require, exports, module) {
|
|||||||
var cm = editor._codeMirror;
|
var cm = editor._codeMirror;
|
||||||
var gutters = cm.getOption("gutters").slice(0);
|
var gutters = cm.getOption("gutters").slice(0);
|
||||||
var index = gutters.indexOf(GUTTER_NAME);
|
var index = gutters.indexOf(GUTTER_NAME);
|
||||||
var rootElement = editor.getRootElement();
|
$(editor.getRootElement()).removeClass("folding-enabled");
|
||||||
$(rootElement).removeClass("folding-enabled");
|
|
||||||
gutters.splice(index, 1);
|
gutters.splice(index, 1);
|
||||||
cm.setOption("gutters", gutters);
|
cm.setOption("gutters", gutters);
|
||||||
// Force recomputing gutter width - .folding-enabled class affected linenumbers gutter
|
cm.refresh(); // force recomputing gutter width - .folding-enabled class affected linenumbers gutter
|
||||||
cm.refresh();
|
|
||||||
CodeMirror.defineOption("foldGutter", false, null);
|
CodeMirror.defineOption("foldGutter", false, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,39 +316,6 @@ define(function (require, exports, module) {
|
|||||||
if (editor._codeMirror.getOption("gutters").indexOf(GUTTER_NAME) === -1) {
|
if (editor._codeMirror.getOption("gutters").indexOf(GUTTER_NAME) === -1) {
|
||||||
createGutter(editor);
|
createGutter(editor);
|
||||||
restoreLineFolds(editor);
|
restoreLineFolds(editor);
|
||||||
// Watch mutations on code mirror gutters and ensure line numbers are added before fold gutter.
|
|
||||||
var config = {childList: true};
|
|
||||||
var gutters,
|
|
||||||
lineNumberIndex,
|
|
||||||
foldGutterIndex,
|
|
||||||
cm = editor._codeMirror,
|
|
||||||
rootElement = editor.getRootElement(),
|
|
||||||
guttersContainer = $(".CodeMirror-gutters", rootElement),
|
|
||||||
observer = new MutationObserver(function (mutations) {
|
|
||||||
observer.disconnect();
|
|
||||||
// Ensure fold-gutter appears after line numbers.
|
|
||||||
gutters = cm.getOption("gutters").slice(0);
|
|
||||||
lineNumberIndex = gutters.indexOf(LINE_NUMBER_GUTTER);
|
|
||||||
foldGutterIndex = gutters.indexOf(GUTTER_NAME);
|
|
||||||
if (lineNumberIndex > -1 && foldGutterIndex < lineNumberIndex) {
|
|
||||||
gutters.splice(foldGutterIndex, 1);
|
|
||||||
lineNumberIndex = gutters.indexOf(LINE_NUMBER_GUTTER);
|
|
||||||
gutters.splice(lineNumberIndex + 1, 0, GUTTER_NAME);
|
|
||||||
}
|
|
||||||
if (lineNumberIndex < 0) {
|
|
||||||
$(rootElement).addClass("linenumber-disabled");
|
|
||||||
} else {
|
|
||||||
$(rootElement).removeClass("linenumber-disabled");
|
|
||||||
}
|
|
||||||
$(rootElement).addClass("folding-enabled");
|
|
||||||
cm.setOption("gutters", gutters);
|
|
||||||
cm.refresh();
|
|
||||||
createGutter(editor);
|
|
||||||
// Reconnect the observer.
|
|
||||||
observer.observe(guttersContainer[0], config);
|
|
||||||
});
|
|
||||||
observer.observe(guttersContainer[0], config);
|
|
||||||
gutterObservers[editor.document.file.fullPath] = observer;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,12 +371,6 @@ define(function (require, exports, module) {
|
|||||||
Editor.forEveryEditor(function (editor) {
|
Editor.forEveryEditor(function (editor) {
|
||||||
CodeMirror.commands.unfoldAll(editor._codeMirror);
|
CodeMirror.commands.unfoldAll(editor._codeMirror);
|
||||||
removeGutter(editor);
|
removeGutter(editor);
|
||||||
//disconnect any mutation observers on the gutter
|
|
||||||
var gutterObserver = gutterObservers[editor.document.file.fullPath];
|
|
||||||
if (gutterObserver) {
|
|
||||||
gutterObserver.disconnect();
|
|
||||||
delete gutterObservers[editor.document.file.fullPath];
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,10 +387,10 @@ define(function (require, exports, module) {
|
|||||||
// don't, we register helpers explicitly here. We also register a global helper for generic indent-based
|
// don't, we register helpers explicitly here. We also register a global helper for generic indent-based
|
||||||
// folding, which cuts across all languages if enabled via preference.
|
// folding, which cuts across all languages if enabled via preference.
|
||||||
CodeMirror.registerGlobalHelper("fold", "selectionFold", function (mode, cm) {
|
CodeMirror.registerGlobalHelper("fold", "selectionFold", function (mode, cm) {
|
||||||
return prefs.getSetting(MAKE_SELECTION_FOLDABLE);
|
return prefs.getSetting("makeSelectionsFoldable");
|
||||||
}, selectionFold);
|
}, selectionFold);
|
||||||
CodeMirror.registerGlobalHelper("fold", "indent", function (mode, cm) {
|
CodeMirror.registerGlobalHelper("fold", "indent", function (mode, cm) {
|
||||||
return prefs.getSetting(ALWAYS_USE_INDENT_FOLD);
|
return prefs.getSetting("alwaysUseIndentFold");
|
||||||
}, indentFold);
|
}, indentFold);
|
||||||
|
|
||||||
CodeMirror.registerHelper("fold", "django", CodeMirror.helpers.fold.brace);
|
CodeMirror.registerHelper("fold", "django", CodeMirror.helpers.fold.brace);
|
||||||
|
@ -49,24 +49,6 @@
|
|||||||
padding-right: 5px;
|
padding-right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If line numbers are not shown and codefolding is enabled we remove the left padding.
|
|
||||||
// We add the same padding below to the fold gutter
|
|
||||||
.show-line-padding {
|
|
||||||
.folding-enabled.linenumber-disabled pre {
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror.linenumber-disabled {
|
|
||||||
// When there are no line numbers, .show-line-padding class adds 15px left padding to line numbers.
|
|
||||||
// Here we compensate for that gap by adding the same padding to the folding gutter.
|
|
||||||
.CodeMirror-foldgutter,
|
|
||||||
.CodeMirror-foldgutter-open,
|
|
||||||
.CodeMirror-foldgutter-folded,
|
|
||||||
.CodeMirror-foldgutter-blank {
|
|
||||||
padding-left: 15px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.CodeMirror-foldmarker {
|
.CodeMirror-foldmarker {
|
||||||
// Re-enabling the pointer events for the fold marker. As pointer events are disabled for "CodeMirror-lines"
|
// Re-enabling the pointer events for the fold marker. As pointer events are disabled for "CodeMirror-lines"
|
||||||
|
Loading…
Reference in New Issue
Block a user