@parcel/codeframe 2.0.0-nightly.1140 → 2.0.0-nightly.1159

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/codeframe.js CHANGED
@@ -35913,6 +35913,7 @@ function $796233c1fee0ccb8$export$2e2bcd8739ae039(code, highlights, inputOpts =
35913
35913
  let { lineNumber: lineNumber , lineNumberLength: lineNumberLength , isHighlighted: isHighlighted } = params;
35914
35914
  return `${isHighlighted ? highlighter(">") : " "} ${lineNumber ? lineNumber.padStart(lineNumberLength, " ") : " ".repeat(lineNumberLength)} | `;
35915
35915
  }; // Make columns/lines start at 1
35916
+ let originalHighlights = highlights;
35916
35917
  highlights = highlights.map((h)=>{
35917
35918
  return {
35918
35919
  start: {
@@ -35931,7 +35932,14 @@ function $796233c1fee0ccb8$export$2e2bcd8739ae039(code, highlights, inputOpts =
35931
35932
  let startLine = firstHighlight.start.line - opts.padding.before;
35932
35933
  startLine = startLine < 0 ? 0 : startLine;
35933
35934
  let endLineIndex = lastHighlight.end.line + opts.padding.after;
35934
- endLineIndex = endLineIndex - startLine > opts.maxLines ? startLine + opts.maxLines - 1 : endLineIndex;
35935
+ let tail;
35936
+ if (endLineIndex - startLine > opts.maxLines) {
35937
+ let maxLine = startLine + opts.maxLines - 1;
35938
+ highlights = highlights.filter((h)=>h.start.line < maxLine);
35939
+ lastHighlight = highlights[0];
35940
+ endLineIndex = Math.min(maxLine, lastHighlight.end.line + opts.padding.after);
35941
+ tail = originalHighlights.filter((h)=>h.start.line > endLineIndex);
35942
+ }
35935
35943
  let lineNumberLength = (endLineIndex + 1).toString(10).length; // Split input into lines and highlight syntax
35936
35944
  let lines = code.split($796233c1fee0ccb8$var$NEWLINE);
35937
35945
  let syntaxHighlightedLines = (opts.syntaxHighlighting ? $796233c1fee0ccb8$var$highlightSyntax(code, opts.language) : code).replace($796233c1fee0ccb8$var$TAB_REPLACE_REGEX, $796233c1fee0ccb8$var$TAB_REPLACEMENT).split($796233c1fee0ccb8$var$NEWLINE); // Loop over all lines and create codeframe
@@ -36001,7 +36009,9 @@ function $796233c1fee0ccb8$export$2e2bcd8739ae039(code, highlights, inputOpts =
36001
36009
  isHighlighted: true
36002
36010
  }) + highlightLine);
36003
36011
  }
36004
- return resultLines.join("\n");
36012
+ let result = resultLines.join("\n");
36013
+ if (tail && tail.length > 0) result += "\n\n" + $796233c1fee0ccb8$export$2e2bcd8739ae039(code, tail, inputOpts);
36014
+ return result;
36005
36015
  }
36006
36016
 
36007
36017