Skip to content
Prev Previous commit
Next Next commit
repl: fix preview bug in case of long lines
This addresses an issue that is caused by lines that exceed the
current window columns. That would cause the preview to confuse the
REPL. This is meant as hot fix. The preview should be able to handle
these cases appropriately as well later on.
  • Loading branch information
BridgeAR committed Dec 14, 2019
commit 707cba4493ddafa16723e33cf139eb934680a1a3
10 changes: 10 additions & 0 deletions lib/internal/repl/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,16 @@ function setupPreview(repl, contextSymbol, bufferSymbol, active) {
return;
}

// Do not show previews in case the current line is longer than the column
// width.
// TODO(BridgeAR): Fix me. This should not be necessary. It currently breaks
// the output though. We also have to check for characters that have more
// than a single byte as length. Check Interface.prototype._moveCursor. It
// contains the necessary logic.
if (repl.line.length + repl._prompt.length > repl.columns) {
return;
}

// Add the autocompletion preview.
// TODO(BridgeAR): Trigger the input preview after the completion preview.
// That way it's possible to trigger the input prefix including the
Expand Down