code: function _selectAndScrollTo(editor, selections, center, preferNoScroll) {
          var primarySelection = _.find(selections, function (sel) { return sel.primary; }) || _.last(selections),
              resultVisible = editor.isLineVisible(primarySelection.start.line),
              centerOptions = Editor.BOUNDARY_CHECK_NORMAL;
  
          if (preferNoScroll && resultVisible) {
              // no need to scroll if the line with the match is in view
              centerOptions = Editor.BOUNDARY_IGNORE_TOP;
          }
  
          // Make sure the primary selection is fully visible on screen.
          var primary = _.find(selections, function (sel) {
              return sel.primary;
          });
          if (!primary) {
              primary = _.last(selections);
          }
  
          editor._codeMirror.scrollIntoView({from: primary.start, to: primary.end});
          editor.setSelections(selections, center, centerOptions);
      }
docs: @private
  Sets the given selections in the editor and applies some heuristics to determine whether and how we should
  center the primary selection.
  
  @param {!Editor} editor The editor to search in
  @param {!Array<{start:{line:number, ch:number}, end:{line:number, ch:number}, primary:boolean, reversed: boolean}>} selections
  The selections to set. Must not be empty.
  @param {boolean} center Whether to try to center the primary selection vertically on the screen. If false, the selection will still be scrolled
  into view if it's offscreen, but will not be centered.
  @param {boolean=} preferNoScroll If center is true, whether to avoid scrolling if the hit is in the top half of the screen. Default false.