with `scale_with_window=no` script option, `first_match_to_print` increases when shrinking the window and no longer decreases when expanding the window, causing empty lines at the bottom of menu and a chain reaction of the script crashing due to the mouse wheel scrolling up. this commit trys to decrease `first_match_to_print` when its value is abnormal. Closes #16682