Skip to content

Commit

Permalink
Merge branch 'master' into addCSSRoute-#1097
Browse files Browse the repository at this point in the history
  • Loading branch information
calculuschild authored Aug 27, 2024
2 parents 3d3ad3f + a6a1d70 commit 786acc7
Show file tree
Hide file tree
Showing 3 changed files with 15,473 additions and 15,431 deletions.
19 changes: 17 additions & 2 deletions client/homebrew/editor/editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,18 @@ const Editor = createClass({

codeMirror.operation(()=>{ // Batch CodeMirror styling

const foldLines = [];

//reset custom text styles
const customHighlights = codeMirror.getAllMarks().filter((mark)=>!mark.__isFold); //Don't undo code folding
const customHighlights = codeMirror.getAllMarks().filter((mark)=>{
// Record details of folded sections
if(mark.__isFold) {
const fold = mark.find();
foldLines.push({from: fold.from?.line, to: fold.to?.line});
}
return !mark.__isFold;
}); //Don't undo code folding

for (let i=customHighlights.length - 1;i>=0;i--) customHighlights[i].clear();

let editorPageCount = 2; // start page count from page 2
Expand All @@ -148,6 +158,11 @@ const Editor = createClass({
codeMirror.removeLineClass(lineNumber, 'text');
codeMirror.removeLineClass(lineNumber, 'wrap', 'sourceMoveFlash');

// Don't process lines inside folded text
// If the current lineNumber is inside any folded marks, skip line styling
if (foldLines.some(fold => lineNumber >= fold.from && lineNumber <= fold.to))
return;

// Styling for \page breaks
if((this.props.renderer == 'legacy' && line.includes('\\page')) ||
(this.props.renderer == 'V3' && line.match(/^\\page$/))) {
Expand Down Expand Up @@ -260,7 +275,7 @@ const Editor = createClass({
// Iterate over conflicting marks and clear them
var marks = codeMirror.findMarks(startPos, endPos);
marks.forEach(function(marker) {
marker.clear();
if(!marker.__isFold) marker.clear();
});
codeMirror.markText(startPos, endPos, { className: 'emoji' });
}
Expand Down
Loading

0 comments on commit 786acc7

Please sign in to comment.