Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fixed matches sorting in shortcodeConverter. #4270
It looks like the algorithm to compute and return shortcode pieces array is dependent on ascending sorting of the matches and the sorting was not ascending causing a series of bugs and unexpected behaviours.
This PR just changes sorting in shortcodeConverter function to be ascending as it looks like is what the algorithm expects.
How Has This Been Tested?
Paste into a simple text editor first to make sure pasting is plain text. Copying from here escapes content.
Verify the output is an image block as expected.
Load the post in Gutenberg use convert to blocks option and verify the result is similar to what we add in the classic editor.
Verify "simple" shortcode pasting works as before.
Screenshots (jpeg or gifs if applicable):
Hi @iseulde, thank you for your review. It is a good indication that this solves the problem if both of us arrived to the same fix :) Yes, the array keys are strings, but given that we are applying the "-" arithmetic operator the values get converted to integers before the operator execution, so I decided to not have parseInt in order for the code to be simpler.