search: correctly merge token ranges
Created by: rvantonder
Stacked on #12188.
Some parts of the parser didn't correctly update pattern ranges for a merge operation. There was also one missing case where the range wasn't assigned. This PR fixes it.