Issue 6850 Part I: Added CodeMirror search addon
Split logic for getting the next document into its own function