mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-06 07:52:40 +00:00
Add @import folding
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
registerHomebreweryHelper : function(CodeMirror) {
|
registerHomebreweryHelper : function(CodeMirror) {
|
||||||
CodeMirror.registerHelper('fold', 'homebrewerycss', function(cm, start) {
|
CodeMirror.registerHelper('fold', 'homebrewerycss', function(cm, start) {
|
||||||
|
|
||||||
|
// BRACE FOLDING
|
||||||
const startMatcher = /\{[ \t]*$/;
|
const startMatcher = /\{[ \t]*$/;
|
||||||
const endMatcher = /\}[ \t]*$/;
|
const endMatcher = /\}[ \t]*$/;
|
||||||
const prevLine = cm.getLine(start.line);
|
const prevLine = cm.getLine(start.line);
|
||||||
|
|
||||||
if((start.line === cm.firstLine()) && (!cm.getLine(start.line).match(startMatcher))) return null;
|
|
||||||
|
|
||||||
if(start.line === cm.firstLine() || prevLine.match(startMatcher)) {
|
if(prevLine.match(startMatcher)) {
|
||||||
const lastLineNo = cm.lastLine();
|
const lastLineNo = cm.lastLine();
|
||||||
let end = start.line + 1;
|
let end = start.line + 1;
|
||||||
let braceCount = 1;
|
let braceCount = 1;
|
||||||
@@ -26,6 +27,17 @@ module.exports = {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IMPORT FOLDING
|
||||||
|
|
||||||
|
const importMatcher = /^@import.*?[;]/;
|
||||||
|
|
||||||
|
if(prevLine.match(importMatcher)) {
|
||||||
|
return {
|
||||||
|
from : CodeMirror.Pos(start.line, 0),
|
||||||
|
to : CodeMirror.Pos(start.line, cm.getLine(start.line).length)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user