From af761da811e45808d9f1068eaaf3deecd05b4a53 Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Sun, 23 Aug 2020 08:54:45 -0700 Subject: [PATCH] Allow windows console users to exit with ctrl+c On windows with jline3, inputting ctrl+c in the sbt console just causes the input stream to return -3 unlike mac and linux where ctrl+c always signals. Fixes https://github.com/sbt/sbt/issues/5791 --- .../src/main/scala/sbt/internal/util/JLine3.scala | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/util-logging/src/main/scala/sbt/internal/util/JLine3.scala b/internal/util-logging/src/main/scala/sbt/internal/util/JLine3.scala index 953042b72..6c086f458 100644 --- a/internal/util-logging/src/main/scala/sbt/internal/util/JLine3.scala +++ b/internal/util-logging/src/main/scala/sbt/internal/util/JLine3.scala @@ -108,9 +108,12 @@ private[sbt] object JLine3 { } case _ => throw new ClosedException } - if (res == 4 && term.prompt.render().endsWith(term.prompt.mkPrompt())) - throw new ClosedException - res + res match { + case 3 /* ctrl+c */ => throw new ClosedException + case 4 /* ctrl+d */ if term.prompt.render().endsWith(term.prompt.mkPrompt()) => + throw new ClosedException + case r => r + } } } override val output: OutputStream = new OutputStream {