File tree Expand file tree Collapse file tree
src/vs/workbench/contrib/terminalContrib/chatAgentTools Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -603,9 +603,11 @@ export function detectsHighConfidenceInputPattern(cursorLine: string): boolean {
603603 / : \s * \( [ ^ ) ] * \) + $ / ,
604604 // Line contains (END) which is common in pagers
605605 / \( E N D \) $ / ,
606- // Password prompt (must be followed by optional colon and trailing space to indicate
607- // an active prompt; otherwise normal output containing the word "password" would match).
608- / p a s s w o r d : ? + $ / i,
606+ // Password prompt. Requires a trailing colon (e.g. "Password:", "[sudo] password for user:")
607+ // and tolerates zero or more trailing spaces — xterm's `translateToString(trimRight=true)`
608+ // strips trailing whitespace from non-wrapped buffer lines, so a real `Password: ` prompt
609+ // is captured from the buffer as `Password:` with no trailing space.
610+ / p a s s w o r d (?: f o r [ ^ : ] + ) ? : \s * $ / i,
609611 // "Press a key" or "Press any key"
610612 / p r e s s a (?: n y ) ? k e y / i,
611613 // Interactive prompt libraries (prompts, enquirer, inquirer) prefix the prompt with
Original file line number Diff line number Diff line change @@ -460,6 +460,13 @@ suite('OutputMonitor', () => {
460460 } ) ;
461461 test ( 'matches password and press-any-key prompts' , ( ) => {
462462 assert . strictEqual ( detectsHighConfidenceInputPattern ( 'Password: ' ) , true ) ;
463+ // xterm's translateToString(trimRight=true) strips trailing whitespace from
464+ // non-wrapped buffer lines, so a real `Password: ` prompt is captured as
465+ // `Password:` with no trailing space (e.g. when running `sudo su`).
466+ assert . strictEqual ( detectsHighConfidenceInputPattern ( 'Password:' ) , true ) ;
467+ // The colon is required: a bare line ending with the word "password" should
468+ // not match (avoids false positives on log/help output that mentions the word).
469+ assert . strictEqual ( detectsHighConfidenceInputPattern ( 'Enter your password' ) , false ) ;
463470 assert . strictEqual ( detectsHighConfidenceInputPattern ( 'Press any key to continue...' ) , true ) ;
464471 } ) ;
465472 test ( 'matches parenthesized defaults' , ( ) => {
You can’t perform that action at this time.
0 commit comments