laravel / prompts

Beautiful and user-friendly forms for your command-line PHP applications.
https://laravel.com/docs/prompts
MIT License
533 stars 94 forks source link

Fix output of escape characters when using `NullOutput` interface #28

Closed jessarcher closed 1 year ago

jessarcher commented 1 year ago

This PR fixes an issue when the output interface has been set to a NullOutput instance (e.g. when using the callSilent method in Laravel).

Currently, cursor manipulation and erase escape sequences are written directly to STDOUT because they interfere with the trailing newline calculation. However, when a NullOutput instance is used, the escape sequences are still output while the rest of the output is dropped.

When using Laravel's OutputStyle, we can bypass its newline calculation by writing directly to the underlying OutputInterface using the getOutput method.

When used without Laravel, I've added a writeDirectly method to the ConsoleOutput class that bypasses the calculation.

This partially solves #22, but a framework PR is required to completely solve it.