Fix broken indention on Windows systems because of line endings#4221
Fix broken indention on Windows systems because of line endings#4221danielbachhuber merged 1 commit intowp-cli:masterfrom electrokit:master
Conversation
|
Thanks for the pull request, @electrokit. I appreciate your effort on it. At this point, I'm 👎 on merging this for a couple of reasons:
|
|
Back when there were typewriters CR was moving the cartridge, LF was moving the paper. Nowaday there is "Ubuntu for Windows" https://msdn.microsoft.com/en-us/commandline/wsl/about |
|
That last commit is the way to go, following the 2 golden rules in these situations:
In between you just deal with the normalized input, ie I couldn't resist doing this, see gitlost#14, although it will probably go nowhere. It'd be interesting anyway if you @electrokit could give it a bash (do you have the |
|
@danielbachhuber, is the update acceptable? The two changes should not do anything different in *nix environments with files with LF line endings. |
|
@electrokit Yes, I'm fine with this pull request as it stands now. |
$docComment = preg_replace( '/\R/', "\n", $docComment );should just be $docComment = str_replace( "\r\n", "\n", $docComment ); |
|
@gitlost Can you submit in a new PR? |
|
Will do... |
|
|
|
Ha! Also on ZX Spectrums... curious, do you have the |
|
@electrokit I don't quite understand the Mac OS 9 comment. Was that meant to be a joke or does it reflect a serious consideration? |
|
Mostly a joke, just that I think that \R results in nicer code (removes the definition of newlines away from the code). But for performance reasons alone (around a factor 2), I think the code that @gitlost wrote is better. |
|
👍 Thanks @gfolin |
|
Just so everyone knows, I'm @electrokit as well. Work account. |
For issue #4220
This isn't tested, except in my home environment. The super-critical parts are
php/WP_CLI/Dispatcher/CommandFactory.php
php/WP_CLI/Dispatcher/Subcommand.php:30
preg_match_all( '/(.+?)\R+:/', $longdesc, $matches );php/WP_CLI/DocParser.php:73
This also fixes the wp help command, which screwed up indentation on win systems, regardless of line endings in file.