GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Module "node:readline" doesn't address escape sequence of cursor position report from terminal, causing part of it to flow into input stream as regular string · Issue #57602 · nodejs/node Closed as not planned Labels staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure. DescriptionVersion22.14.0 PlatformSubsystemnode:readline What steps will reproduce the bug?You can reproduce it by running the following script in a terminal: import * as readline from 'node:readline'; const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); const dumpedKeys = [] process.stdin.on('keypress', (s, key)=>{ dumpedKeys.push(key) }) process.stdout.write('You will see an R here -->') process.stdout.write('\x1b[6n'); setTimeout(()=>{ process.stdout.write('\nEmitted keypress events: ' + JSON.stringify(dumpedKeys, null, 2)) dumpedKeys.splice(0) process.stdout.write('\nBut not here \n-->') process.stdout.write('\x1b[6n'); setTimeout(()=>{ process.stdout.write('\nEmitted keypress events: ' + JSON.stringify(dumpedKeys, null, 2)) rl.close() }, 100) }, 100) How often does it reproduce? Is there a required condition?I have tested on Windows terminal & msys2, and identified the problem in source code: node/lib/internal/readline/utils.js Lines 108 to 188 in c3b6f94
What is the expected behavior? Why is that the expected behavior?The reported back string like "\u001b[12;34R" (means row 12, column 34) should be considered together, avoid part of it flowing into normal input stream as regular string. It will be best if it can support arbitray longer valid values, for example "\u001b[1234;5678R" (though in real life hardly will any terminal be such large) What do you see instead?If the cursor position makes the report string longer than 7 chars (like "\u001b[12;34R"), the part after the 7th char will flow into normal input stream causing it to appear on screen and mess up user input. Additional informationFixing it would be helpful for developing interactive console programs that needs current cursor position on screen after writing to output, which can be used as a workaround for nodejs/help#49 (comment) until an official api is implemented. Activity
MetadataMetadataAssigneesLabelsstaleIssues and PRs marked stale due to inactivity and scheduled for automatic closure. TypeProjectsMilestoneRelationshipsDevelopmentIssue actions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |