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.

PR-URL: https://github.com/nodejs/node/pull/30907
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Ruben Bridgewater authored and Michaël Zasso committed 2020-04-28 16:00:29 +02:00
1 parent bf9ff16412
commit 47dfa22adb
1 file changed
+10
+10
View File
@@ -280,6 +280,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