Two things to do that can help
One - don't dimension to end points; specifically select the line itself
Two - if that's a problem, as it is sometimes, use centerlines to dimension to and align the geometry to the centerlines.
Centerlines are poorly named as they are only the center sometimes. But I can't think of a better name.
You can also add sketched points at the intersections of the centerlines and dimension to those also. Since centerlines and points cannot be trimmed, the related dimensions can't be lost.
As a further extension for centerline use; never dimension to part geometry or datums if the sketch might be reused. Place a centerline and align that to the part reference and then dimension from that. This will allow saving the sketch with all suitable dimensions in place and ready to re-use. It also insulates if the feature needs to move or the underlying geometry is replaced. All that is required to repair the sketch is to re-align the centerlines to suitable references and no dimensions or associated notes/tolerances/et al will be lost. Saves a lot of time because, done right, any drawing using those dimensions will be minimally affected.