 
     if ranges.length
       @editor.setSelectedBufferRanges(ranges)
-      unless @isMode('visual', 'characterwise')
-        @activateMode('visual', 'characterwise')
+      @activateMode('visual', 'characterwise') unless @isMode('visual', 'characterwise')
 
 class SelectAllInRangeMarker extends AddSelection
   @extend()


class AddSelection extends Operator
  @extend()

  execute: ->
    lastSelection = @editor.getLastSelection()
    lastSelection.selectWord() unless @isMode('visual')
    word = @editor.getSelectedText()
    return if word is ''
    return unless @selectTarget()

    ranges = []
    pattern = if @isMode('visual')
      ///#{_.escapeRegExp(word)}///g
    else
      ///\b#{_.escapeRegExp(word)}\b///g

    for selection in @editor.getSelections()
      scanRange = selection.getBufferRange()
      @editor.scanInBufferRange pattern, scanRange, ({range}) ->

  isEndsWithNewLineForBufferRow
  isAllWhiteSpace
  isSingleLine
  getCharacterAtCursor
} = require './utils'
swrap = require './selection-wrapper'
settings = require './settings'
