Make getModeForRange() behave like getModeForSelection() when mode is not mixed

For #7764. This isn't the cleanest fix, but it exactly preserves the existing behavior for the case where `getModeForRange()` is called from `getModeForSelection()`, while fixing the behavior for the case where `getModeForRange()` is called directly from the commenting operations in EditorCommandHandlers.

The EditorCommandHandlers unit tests all pass with this fix.

@peterflynn /cc @TomMalbran