Review the original item:
Mike has terrible eating habits when he opened
his lunch bag, we saw a bag of potato chips, two candy bars, cellophane-wrapped
cupcakes, and a carton of chocolate milk.
You chose the correct way to fix the error:
Mike has terrible eating habits;
when he opened his lunch bag, we saw a bag of potato chips, two candy
bars, cellophane-wrapped cupcakes, and a carton of chocolate milk.
Mike has terrible eating habits is a complete sentence. When he opened his lunch bag, we saw ... begins the second complete sentence.
You are always correct when you use a semicolon to join two complete sentences closely related in meaning.