Skip to content

Commit

Permalink
fix #152 ^[[0m is inserted in stderr for echo code | nim c -
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed May 4, 2020
1 parent b6fb609 commit 73bd9f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/msgs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ template styledMsgWriteln*(args: varargs[typed]) =
else:
if eStdErr in conf.m.errorOutputs:
if optUseColors in conf.globalOptions:
# conf.options.ansiResetNeeded = true
conf.ansiResetNeeded = true
callStyledWriteLineStderr(args)
else:
callIgnoringStyle(writeLine, stderr, args)
Expand Down Expand Up @@ -443,7 +445,8 @@ proc rawMessage*(conf: ConfigRef; msg: TMsgKind, arg: string) =

proc resetAttributes*(conf: ConfigRef) =
if {optUseColors, optStdout} * conf.globalOptions == {optUseColors}:
terminal.resetAttributes(stderr)
if conf.ansiResetNeeded:
terminal.resetAttributes(stderr)

proc addSourceLine(conf: ConfigRef; fileIdx: FileIndex, line: string) =
conf.m.fileInfos[fileIdx.int32].lines.add line
Expand Down
1 change: 1 addition & 0 deletions compiler/options.nim
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ type
projectPath*: AbsoluteDir # holds a path like /home/alice/projects/nim/compiler/
projectFull*: AbsoluteFile # projectPath/projectName
projectIsStdin*: bool # whether we're compiling from stdin
ansiResetNeeded*: bool # whether resetAttributes is needed
projectMainIdx*: FileIndex # the canonical path id of the main module
command*: string # the main command (e.g. cc, check, scan, etc)
commandArgs*: seq[string] # any arguments after the main command
Expand Down

0 comments on commit 73bd9f7

Please sign in to comment.