Skip to content

Commit

Permalink
Merge pull request #216 from Numpsy/console_colours
Browse files Browse the repository at this point in the history
Reset the console foreground colour with control codes
  • Loading branch information
dawedawe authored Jul 30, 2024
2 parents bee7ea7 + 86e7d76 commit 6dd3cd1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed
* [Reset the console foreground colour after printing results](https://github.com/ionide/FSharp.Analyzers.SDK/pull/216) (thanks @Numpsy!)

## [0.26.0] - 2024-05-15

### Changed
Expand Down
6 changes: 4 additions & 2 deletions src/FSharp.Analyzers.Cli/CustomLogging.fs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type CustomFormatter(options: IOptionsMonitor<CustomOptions>) as this =
if formatterOptions.UseAnalyzersMsgStyle then
this.SetColor(textWriter, logEntry.LogLevel)
textWriter.WriteLine(message)
this.ResetColor()
this.ResetColor(textWriter)
else
this.WritePrefix(textWriter, logEntry.LogLevel)
textWriter.WriteLine(message)
Expand Down Expand Up @@ -72,7 +72,9 @@ type CustomFormatter(options: IOptionsMonitor<CustomOptions>) as this =

textWriter.Write(color)

member private _.ResetColor() = Console.ForegroundColor <- origColor
member private _.ResetColor(textWriter: TextWriter) =
textWriter.Write("\x1B[0m")
Console.ForegroundColor <- origColor

interface IDisposable with
member _.Dispose() = optionsReloadToken.Dispose()
Expand Down

0 comments on commit 6dd3cd1

Please sign in to comment.