 isGitRepository = (path) ->
   fs.isDirectorySync _path.join(path, '.git')
 
+highlightMatches = (context, path, matches, offsetIndex=0) ->
+  lastIndex = 0
+  matchedChars = [] # Build up a set of matched chars to be more semantic
+
+  for matchIndex in matches
+    matchIndex -= offsetIndex
+    continue if matchIndex < 0 # If marking up the basename, omit path matches
+    unmatched = path.substring(lastIndex, matchIndex)
+    if unmatched
+      context.span matchedChars.join(''), class: 'character-match' if matchedChars.length
+      matchedChars = []
+      context.text unmatched
+    matchedChars.push(path[matchIndex])
+    lastIndex = matchIndex + 1
+
+  context.span matchedChars.join(''), class: 'character-match' if matchedChars.length
+  # Remaining characters are plain text
+  context.text path.substring(lastIndex)
+
 class View extends SelectListView
   # Copied from FuzzzyFinder's and modified a little.
-  @highlightMatches: (context, path, matches, offsetIndex=0) ->
-    lastIndex = 0
-    matchedChars = [] # Build up a set of matched chars to be more semantic
-
-    for matchIndex in matches
-      matchIndex -= offsetIndex
-      continue if matchIndex < 0 # If marking up the basename, omit path matches
-      unmatched = path.substring(lastIndex, matchIndex)
-      if unmatched
-        context.span matchedChars.join(''), class: 'character-match' if matchedChars.length
-        matchedChars = []
-        context.text unmatched
-      matchedChars.push(path[matchIndex])
-      lastIndex = matchIndex + 1
-
-    context.span matchedChars.join(''), class: 'character-match' if matchedChars.length
-    # Remaining characters are plain text
-    context.text path.substring(lastIndex)
-
   initialize: ->
     super
     @addClass('project-folder')


  populateList: ->
    super
    @removeClass 'add remove'
    @addClass @action

  # @action should be 'add' or 'remove'
  start: (@action) ->
    @storeFocusedElement()
    @setItems @getItems()
    @panel.show()
    @focusFilterEditor()

  confirmAndContinue: ->
    selectedItem = @getSelectedItem()
    return unless selectedItem?
    this[@action](fs.normalize(selectedItem))

    selectedItemView = @getSelectedItemView()
    @selectNextItemView()
    selectedItemView.remove()
    @items = (item for item in @items when item isnt selectedItem)

  confirmed: (item) ->
    this[@action] fs.normalize(item)
    @cancel()

  cancelled: ->

          dirs = _.reject(dirs, (path) -> path in loadedPaths)

    dirs.map (dir) ->
      itemPath = dir.replace(fs.getHomeDirectory(), '~')
      if itemPath.startsWith("~/github/atom-cursor-history")
        itemType = 'group'
      else
        itemType = 'repo'
      {itemPath, itemType}

  getNormalDirectories: ->
    dirs = []
