Merge pull request #2281 from eamelink/bugfix-1982

Fix search result highlighting on Windows
This commit is contained in:
eugene yokota 2015-11-27 15:36:50 -05:00
commit a9d80cf38c
2 changed files with 14 additions and 4 deletions

View File

@ -6,19 +6,18 @@ import scala.Console.{ BOLD, RESET }
import sbt.internal.util.ConsoleLogger
object Highlight {
final val NormalIntensity = "\033[22m"
final val NormalTextColor = "\033[39m"
def showMatches(pattern: Pattern)(line: String): Option[String] =
{
val matcher = pattern.matcher(line)
if (ConsoleLogger.formatEnabled) {
val highlighted = matcher.replaceAll(scala.Console.RED + "$0" + NormalTextColor)
// ANSI codes like \033[39m (normal text color) don't work on Windows
val highlighted = matcher.replaceAll(scala.Console.RED + "$0" + RESET)
if (highlighted == line) None else Some(highlighted)
} else if (matcher.find)
Some(line)
else
None
}
def bold(s: String) = if (ConsoleLogger.formatEnabled) BOLD + s + NormalIntensity else s
def bold(s: String) = if (ConsoleLogger.formatEnabled) BOLD + s.replace(RESET, RESET + BOLD) + RESET else s
}

View File

@ -0,0 +1,11 @@
[@eamelink]: https://github.com/eamelink
[1982]: https://github.com/sbt/sbt/issues/1982
### Changes with compatibility implications
### Improvements
### Fixes
- Highlighting of partial task search results now only uses ANSI color
codes are supported on Windows [#1982][1982] by [@eamelink][@eamelink]