mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
Merge pull request #3543 from ysmood/err_info_issue
Fixed an error formatting issue
This commit is contained in:
commit
df8529fbfb
3 changed files with 13 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in a new issue