@parcel/codeframe 2.6.2 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/codeframe.js +90 -80
- package/lib/codeframe.js.map +1 -1
- package/package.json +2 -2
- package/src/codeframe.js +19 -5
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@parcel/codeframe",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.7.0",
|
4
4
|
"description": "Blazing fast, zero configuration web application bundler",
|
5
5
|
"license": "MIT",
|
6
6
|
"publishConfig": {
|
@@ -35,5 +35,5 @@
|
|
35
35
|
"string-width": "^4.2.0",
|
36
36
|
"strip-ansi": "^6.0.0"
|
37
37
|
},
|
38
|
-
"gitHead": "
|
38
|
+
"gitHead": "9e5d05586577e89991ccf90400f2c741dca11aa3"
|
39
39
|
}
|
package/src/codeframe.js
CHANGED
@@ -84,6 +84,7 @@ export default function codeFrame(
|
|
84
84
|
};
|
85
85
|
|
86
86
|
// Make columns/lines start at 1
|
87
|
+
let originalHighlights = highlights;
|
87
88
|
highlights = highlights.map(h => {
|
88
89
|
return {
|
89
90
|
start: {
|
@@ -112,10 +113,17 @@ export default function codeFrame(
|
|
112
113
|
let startLine = firstHighlight.start.line - opts.padding.before;
|
113
114
|
startLine = startLine < 0 ? 0 : startLine;
|
114
115
|
let endLineIndex = lastHighlight.end.line + opts.padding.after;
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
116
|
+
let tail;
|
117
|
+
if (endLineIndex - startLine > opts.maxLines) {
|
118
|
+
let maxLine = startLine + opts.maxLines - 1;
|
119
|
+
highlights = highlights.filter(h => h.start.line < maxLine);
|
120
|
+
lastHighlight = highlights[0];
|
121
|
+
endLineIndex = Math.min(
|
122
|
+
maxLine,
|
123
|
+
lastHighlight.end.line + opts.padding.after,
|
124
|
+
);
|
125
|
+
tail = originalHighlights.filter(h => h.start.line > endLineIndex);
|
126
|
+
}
|
119
127
|
|
120
128
|
let lineNumberLength = (endLineIndex + 1).toString(10).length;
|
121
129
|
|
@@ -281,5 +289,11 @@ export default function codeFrame(
|
|
281
289
|
}
|
282
290
|
}
|
283
291
|
|
284
|
-
|
292
|
+
let result = resultLines.join('\n');
|
293
|
+
|
294
|
+
if (tail && tail.length > 0) {
|
295
|
+
result += '\n\n' + codeFrame(code, tail, inputOpts);
|
296
|
+
}
|
297
|
+
|
298
|
+
return result;
|
285
299
|
}
|