Skip to content

Commit 02f3fe4

Browse files
BridgeARMylesBorins
authored andcommitted
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: #30907 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 6a3e79f commit 02f3fe4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/internal/repl/utils.js

+10
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,16 @@ function setupPreview(repl, contextSymbol, bufferSymbol, active) {
280280
return;
281281
}
282282

283+
// Do not show previews in case the current line is longer than the column
284+
// width.
285+
// TODO(BridgeAR): Fix me. This should not be necessary. It currently breaks
286+
// the output though. We also have to check for characters that have more
287+
// than a single byte as length. Check Interface.prototype._moveCursor. It
288+
// contains the necessary logic.
289+
if (repl.line.length + repl._prompt.length > repl.columns) {
290+
return;
291+
}
292+
283293
// Add the autocompletion preview.
284294
// TODO(BridgeAR): Trigger the input preview after the completion preview.
285295
// That way it's possible to trigger the input prefix including the

0 commit comments

Comments
 (0)