Skip to content

Commit

Permalink
fix(cli): Make --watcher CLEAR_SCREEN clear scrollback buffer as well…
Browse files Browse the repository at this point in the history
… as visible screen (#25997)

The --watch option should clear the screen scrollback buffer as well as
the screen itself.

On Ubuntu (22.04 Jammy) the 'clear' command generates
"\x1B[H\x1B[2J\x1B[3J"; that is:
- \E[H  - cursor home
- \E[2J - clear entire screen
- \E[3J - clear entire screen & scrollback buffer.

By contrast, Deno defined CLEAR_SCREEN as "\x1B[2J\x1B[1;1H", which
fails to clear the scrollback buffer.

The "\E[H\E[2J\E[3J" sequence works on MacOS (Sonoma) (using printf);
I'm not able to test on Windows.

Closes #26514
  • Loading branch information
chrisveness authored and bartlomieju committed Oct 29, 2024
1 parent 16f3c31 commit 7a7232c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cli/util/file_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use tokio::sync::mpsc;
use tokio::sync::mpsc::UnboundedReceiver;
use tokio::time::sleep;

const CLEAR_SCREEN: &str = "\x1B[2J\x1B[1;1H";
const CLEAR_SCREEN: &str = "\x1B[H\x1B[2J\x1B[3J";
const DEBOUNCE_INTERVAL: Duration = Duration::from_millis(200);

struct DebouncedReceiver {
Expand Down

0 comments on commit 7a7232c

Please sign in to comment.