module Space
  module Model
    class Project
      autoload :Bundler, 'space/model/project/bundler'
      autoload :Tmux,    'space/model/project/tmux'

      include Events

      attr_reader :name, :repos, :bundler, :config

      def initialize(name)
        @name    = name
        @config  = Config.load(name)
        @repos   = Repos.new(self, config.paths)
        @bundler = Bundler.new(self)
      end

      def local_repos
        bundler.config.keys.map do |key|
          key =~ /^local\.(.+)$/
          $1 if repos.names.include?($1)
        end.compact
      end

      def names
        @names ||= Tmux.windows || repos.names
      end

      def number(name)
        if number = names.index(name)
          number + 1
        else
          names << name
          number(name)
        end
      end

      def refresh
        [bundler, repos].each(&:refresh)
      end
    end
  end
end

module Space
  module Model
    class Project
      autoload :Bundler, 'space/model/project/bundler'
      autoload :Tmux,    'space/model/project/tmux'

      include Events

      attr_reader :name, :repos, :bundler, :config

      def initialize(name)
        @name    = name
        @config  = Config.load(name)
        @repos   = Repos.new(self, config.paths)
        @bundler = Bundler.new(self)
      end

      def local_repos
        bundler.config.keys.map do |key|
          key =~ /^local\.(.+)$/
          $1 if repos.names.include?($1)
        end.compact
      end

      def names
        @names ||= Tmux.windows || repos.names
      end

      def number(name)
        if number = names.index(name)
          number
        else
          names << name
          number(name)
        end
      end

      def refresh
        [bundler, repos].each(&:refresh)
      end
    end
  end
end

Fix improper Dashboard list indexing
[PoC] Fix improper Dashboard list indexing

Having two repos I'm facing improper list indexing
in Dashboard. Here is how it looking https://gist.github.com/a454501c92026be915bf.
Pressing key `1` that corresponds unexising repo is
closing space. 
This fix is Proof of Concept, 'cause I didn't dive
into the inner logic of Dashboard, and removing
this `+1` is most obvious way to fix it.

