Skip to content

Commit

Permalink
Fix prompt length for older versions of node
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Apr 16, 2017
1 parent 31d8715 commit 85b4a85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ if (interactive) {
input: process.stdin,
output: process.stdout,
path: path.join(xdgBasedir.config, "insect-history"),
prompt: '\x1b[01m>>>\x1b[0m ',
completer: function(line) {
var variables = Object.keys(insectEnv);

Expand All @@ -76,6 +75,12 @@ if (interactive) {
return [keywords, lastWord];
},
next: function(rl) {
var prompt = '\x1b[01m>>>\x1b[0m ';

// The visual length of the prompt (4) needs to be set explicitly for
// older versions of node:
rl.setPrompt(prompt, 4);

rl.prompt();

rl.on('line', function(line) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "insect",
"version": "4.1.0",
"version": "4.2.0",
"description": "REPL-style scientific calculator with full support for physical units",
"author": "David Peter <[email protected]>",
"license": "MIT",
Expand Down

0 comments on commit 85b4a85

Please sign in to comment.