Pasting multi-line functions repeats their lines pointlessly

Offen
#67,364 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
javascript, nodejs
Bereich
cli

Rechercherichtung

The bug is in the REPL's multi-line input redraw on Windows, so start in lib/repl.js and the readline-based line refresh logic that re-renders the buffer as the user pastes. Reproduce by pasting the multi-line Fib snippet into node on Windows and confirm the duplicated prompt lines. Done means the pasted function is echoed once per line with no repeated lines, and a test under test/parallel for REPL output passes.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Version

v26.13.0

Platform
Microsoft Windows NT 10.0.19045.0 x64
Subsystem

No response

What steps will reproduce the bug?
  1. Open Node.
  2. Paste:
Fib=I=>{// Iterative Fibonacci , I = Integer ≥ 0
	if(!Number.isInteger(I)||I<0)return'Please enter a positive integer or zero!'
	if(I===0||I===1)return I
	let a=0,b=1,c;--I;do{c=a+b;a=b;b=c}while(--I!==0)// # iterations = I-1
	return c
}// e.g. Fib(7) //➜ 13 , Fib(8) //➜ 21 , Fib(9) //➜ 34

You'll see that it looks like this:

node
Welcome to Node.js v26.13.0.
Type ".help" for more information.
Fib=I=>{// Iterative Fibonacci , I = Integer ≥ 0
Fib=I=>{// Iterative Fibonacci , I = Integer ≥ 0
Fib=I=>{// Iterative Fibonacci , I = Integer ≥ 0
| if(!Number.isInteger(I)||I<0)return'Please enter a positive integer
Fib=I=>{// Iterative Fibonacci , I = Integer ≥ 0
| if(!Number.isInteger(I)||I<0)return'Please enter a positive integer
Fib=I=>{// Iterative Fibonacci , I = Integer ≥ 0
| if(!Number.isInteger(I)||I<0)return'Please enter a positive integer
or zero!'
| if(I===0||I===1)return I
| let a=0,b=1,c;--I;do{c=a+b;a=b;b=c}while(--I!==0)// # iterations = I-1
| return c
| }// e.g. Fib(7) //➜ 13 , Fib(8) //➜ 21 , Fib(9) //➜ 34
[Function: Fib]

How often does it reproduce? Is there a required condition?

It happens every time.

What is the expected behavior? Why is that the expected behavior?

I expect it to work the way that it did in past versions of Node and also as the DevTools console works. Not repeat the same line like 5 times.

What do you see instead?

Lines being repeated, 3 times, 5 times, etc.

Additional information

No response

Vorherrschende Sprache
JavaScript
Sterne
124k
Forks
38k
Ø Merge
4 T. 2 Std.
Gemergte PRs (30 T.)
266

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus nodejs/node

Alle Issues in nodejs/node

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.