Sometimes the damage nees just few stitches. This damage needed whole new zipper. It costed 1,20€ so for sure it is worth of trouble to replace it.
Remove with a seam ripper or scissors only those stitches you need to free the broken zipper.
Try every now and then is the zipper free or not.
Pull the zipper gently out and clean the mess also from the pants. With adhesive tape you can easily get loose end threads out off the fabric.
This is how it looks when the zipper is out.
At first pin this side of the zipper. The side, where's the folded flap. (Compaire with the upper picture.)
Pin it all the way down.
Sew it.
Then you need to pin the folded flap and the other edge of the zipper.
When you look carefully you can see there is one extra vertical stitch line compaired to the original version. There's three original stitch lines; double on the right and single on the left. Yes, you noticed that. So, there's one new extra in the middle of the vertical double and single stitch lines. Now you see it? That makes this zipper replacing easy. It is new but insignificant what comes to its visibility or using the zipper.
Notice the blue stitches. I used different shade thread so that you can notice where you need to secure the stitching and the zipper.