Skip to content

Commit 00b715a

Browse files
authored
fix: erase scrollback when clearing the screen (#2267)
1 parent bc910fa commit 00b715a

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

frontend/src/main/scala/bloop/engine/Interpreter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ object Interpreter {
139139
}
140140

141141
if (!bloop.util.CrossPlatform.isWindows)
142-
state.logger.info("\u001b[H\u001b[2J")
142+
state.logger.info(bloop.util.Console.clearCommand)
143143

144144
// Force the first execution before relying on the file watching task
145145
fg(state).flatMap(newState => watcher.watch(newState, fg))

frontend/src/main/scala/bloop/io/SourceWatcher.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ final class SourceWatcher private (
4242
def runAction(state: State, events: Seq[DirectoryChangeEvent]): Task[State] = {
4343
// Windows is not supported for now
4444
if (!bloop.util.CrossPlatform.isWindows)
45-
logger.info("\u001b[H\u001b[2J") // Clean terminal before acting on the event action
45+
logger.info(bloop.util.Console.clearCommand)
4646
events.foreach(e => logger.debug(s"A ${e.eventType()} in ${e.path()} has triggered an event"))
4747
action(state)
4848
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package bloop.util
2+
3+
object Console {
4+
private val escape = "\u001b["
5+
private val cursorHome = "H"
6+
private val eraseScreen = "2J"
7+
private val eraseScrollbar = "3J"
8+
9+
val clearCommand: String = escape + cursorHome + escape + eraseScreen + escape + eraseScrollbar
10+
}

0 commit comments

Comments
 (0)