How do I make Illustrator not change the gradient's position and size when I change the path's shape?
Essentially you don't. Gradient fills are based on the boundaries of the shape they are applied to. If you alter the boundaries, then the gradient position and length will change. It is simply how gradient fills work.
It's a very simple matter to grab the Gradient Tool and move the annotator to where you want it.
Basically I draw a line parallel to the slider and after changing the shape I make the new slider follow that line. Of course you can also use a piece of tape on your screen. To make it myself easier use the following combinations: line ("\"), gradient tool (G) and select object below (cmd+alt+[)
Another way is to use the Info window to show the slider's coordinates. It also shows the slider's height, width, angle and length. Makes me wonder if someone could make use of this to create a guide line
If you have an object with a gradient and want to change the shape without affecting the gradient, use the Pathfinder "divide", and subtract it with another shape. When it's divided you can delete the parts that you don't need and you'll leave the gradient intact. Try this and let me know if that works for you.