Pasting multi-line functions repeats their lines pointlessly

未关闭
#67,364 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
javascript, nodejs
领域
cli

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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

主要语言
JavaScript
星标
124k
派生
38k
平均合并
4 天 2 小时
30 天内合并 PR
266

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nodejs/node 的其他 Issue

查看 nodejs/node 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。