diff --git a/lib/cli_repl.dart b/lib/cli_repl.dart index 1e3331b..d9c5bec 100644 --- a/lib/cli_repl.dart +++ b/lib/cli_repl.dart @@ -17,7 +17,8 @@ class Repl { {this.prompt: '', String continuation, StatementValidator validator, - this.maxHistory: 50}) + this.maxHistory: 50, + this.logWhitespace: true}) : continuation = continuation ?? ' ' * prompt.length, validator = validator ?? alwaysValid { _adapter = new ReplAdapter(this); @@ -45,6 +46,11 @@ class Repl { /// /// Defaults to 50. int maxHistory; + + /// Should repl history include whitespace-only entries + /// + /// Defaults to true + bool logWhitespace; } /// Returns true if [text] is a complete statement or false otherwise. diff --git a/lib/src/repl_adapter/vm.dart b/lib/src/repl_adapter/vm.dart index 4d10e9c..25604cb 100644 --- a/lib/src/repl_adapter/vm.dart +++ b/lib/src/repl_adapter/vm.dart @@ -227,7 +227,8 @@ class ReplAdapter { String contents = new String.fromCharCodes(buffer); setCursor(buffer.length); input(char); - if (repl.history.isEmpty || contents != repl.history.first) { + if ((repl.history.isEmpty || contents != repl.history.first) + && (contents.trim().isNotEmpty || repl.logWhitespace)) { repl.history.insert(0, contents); } while (repl.history.length > repl.maxHistory) {