Merge pull request #3543 from ysmood/err_info_issue

Fixed an error formatting issue
This commit is contained in:
Michael Ficarra 2014-07-16 07:36:48 -07:00
commit df8529fbfb
3 changed files with 13 additions and 2 deletions

View File

@ -220,7 +220,7 @@
codeLine = this.code.split('\n')[first_line];
start = first_column;
end = first_line === last_line ? last_column + 1 : codeLine.length;
marker = repeat(' ', start) + repeat('^', end - start);
marker = codeLine.slice(0, start).replace(/[^\s]/g, ' ') + repeat('^', end - start);
if (typeof process !== "undefined" && process !== null) {
colorsEnabled = process.stdout.isTTY && !process.env.NODE_DISABLE_COLORS;
}

View File

@ -172,7 +172,7 @@ syntaxErrorToString = ->
start = first_column
# Show only the first line on multi-line errors.
end = if first_line is last_line then last_column + 1 else codeLine.length
marker = repeat(' ', start) + repeat('^', end - start)
marker = codeLine[...start].replace(/[^\s]/g, ' ') + repeat('^', end - start)
# Check to see if we're running on a color-enabled TTY.
if process?

View File

@ -41,6 +41,17 @@ test "compiler error formatting", ->
^^^^
'''
test "compiler error formatting with mixed tab and space", ->
assertErrorFormat """
\t if a
\t test
""",
'''
[stdin]:1:4: error: unexpected if
\t if a
\t ^^
'''
if require?
fs = require 'fs'