You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * moves the cursor to the x and y coordinate on the given stream */functioncursorTo(stream,x,y,callback){if(callback!==undefined&&typeofcallback!=='function')thrownewERR_INVALID_CALLBACK(callback);if(typeofy==='function'){callback=y;y=undefined;}if(stream==null||(typeofx!=='number'&&typeofy!=='number')){if(typeofcallback==='function')process.nextTick(callback,null);returntrue;}if(typeofx!=='number')thrownewERR_INVALID_CURSOR_POS();constdata=typeofy!=='number' ? CSI`${x+1}G` : CSI`${y+1};${x+1}H`;returnstream.write(data,callback);}
Into:
/** * moves the cursor to the x and y coordinate on the given stream */functioncursorTo(stream,x,y,callback){if(callback!==undefined&&typeofcallback!=='function')thrownewERR_INVALID_CALLBACK(callback);if(typeofy==='function'){callback=y;y=undefined;}if(stream==null||(isNaN(x)&&isNaN(y))){if(typeofcallback==='function')process.nextTick(callback,null);returntrue;}if(isNaN(x))thrownewERR_INVALID_CURSOR_POS();constdata=isNaN(y) ? CSI`${x+1}G` : CSI`${y+1};${x+1}H`;returnstream.write(data,callback);}
The text was updated successfully, but these errors were encountered:
unitario
changed the title
Readline 'cursorTo' function incorrectly treats NaN as number
Readline 'cursorTo' function incorrectly treats 'NaN' as a number
Nov 28, 2020
What steps will reproduce the bug?
or
How often does it reproduce? Is there a required condition?
Anytime
NaN
is passed as either x or y coordinates to thecursorTo
function.What is the expected behavior?
When
y
parameter isNaN
, it should throwERR_INVALID_CURSOR_POS
, and log true in the terminal.When
x
parameter isNaN
, the if statement for thedata
variable should evaluate toCSI${x + 1}G
, and log true in the terminal.What do you see instead?
or
Additional information
Change:
Into:
Source: https://github.com/nodejs/node/blob/master/lib/readline.js
The text was updated successfully, but these errors were encountered: