pane: break loop if result was found

(integrated from trunk branch change 7151c7b by Todd Whiteman <toddw@activestate.com>)