Class: CommandT::Finder::MRUBufferFinder

Inherits:
BufferFinder show all
Defined in:
lib/command-t/finder/mru_buffer_finder.rb

Instance Method Summary collapse

Methods inherited from CommandT::Finder

#open_selection, #path=

Constructor Details

#initializeMRUBufferFinder

Returns a new instance of MRUBufferFinder.



7
8
9
10
# File 'lib/command-t/finder/mru_buffer_finder.rb', line 7

def initialize
  @scanner = Scanner::MRUBufferScanner.new
  @matcher = Matcher.new @scanner, :always_show_dot_files => true
end

Instance Method Details

#nameObject



27
28
29
# File 'lib/command-t/finder/mru_buffer_finder.rb', line 27

def name
  'Recent'
end

#sorted_matches_for(str, options = {}) ⇒ Object

Override sorted_matches_for to prevent MRU ordered matches from being ordered alphabetically.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/command-t/finder/mru_buffer_finder.rb', line 14

def sorted_matches_for(str, options = {})
  matches = super(str, options.merge(:sort => false))

  # take current buffer (by definition, the most recently used) and move it
  # to the end of the results
  if MRU.last &&
    relative_path_under_working_directory(MRU.last.name) == matches.first
    matches[1..-1] + [matches.first]
  else
    matches
  end
end