Comparing version 1.0.0 to 1.1.0
@@ -6,2 +6,3 @@ module.exports = pinpoint; | ||
var showLines = options.showLines || 9; | ||
var tabSize = options.tabSize || 4; | ||
var indent = options.indent || ''; | ||
@@ -13,2 +14,3 @@ var line = options.line - 1; | ||
var length = lines.length; | ||
var tabSpaces = repeat(' ', tabSize); | ||
@@ -30,8 +32,16 @@ var start = line; | ||
var maxDigits = end.toString().length; | ||
var tabCount = 0; | ||
var pointedLine = line - start; | ||
lines = lines.slice(start, end).map(function (line, i) { | ||
if (i === pointedLine) { | ||
var pos = 0; | ||
while (pos = 1 + line.indexOf('\t', pos)) { | ||
if (pos <= column) ++tabCount; | ||
} | ||
} | ||
i += start + 1; | ||
return pad(i, maxDigits) + '| ' + line; | ||
return pad(i, maxDigits) + '| ' + line.replace(/\t/g, tabSpaces);; | ||
}); | ||
var arrowLine = repeat('-', maxDigits + 2 + column) + '^'; | ||
lines.splice(line - start + 1, 0, arrowLine); | ||
var arrowLine = repeat('-', maxDigits + 2 + column + tabCount * (tabSize - 1)) + '^'; | ||
lines.splice(pointedLine + 1, 0, arrowLine); | ||
@@ -38,0 +48,0 @@ return indent + lines.join('\n' + indent) |
{ | ||
"name": "pinpoint", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Display an arrow in a string of code to point to a location", | ||
@@ -5,0 +5,0 @@ "main": "lib/pinpoint.js", |
@@ -44,2 +44,3 @@ # pinpoint | ||
* `showLines` - the number of lines to show. The pointed line will try to stay in the middle of the displays lines. | ||
* `indent` - indent string prepend to each line, before the line number. | ||
* `indent` - indent string prepend to each line, before the line number. | ||
* `tabSize` - width of a tab character. |
Sorry, the diff of this file is not supported yet
5724
50
45