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



29
30
31
# File 'lib/command-t/finder/mru_buffer_finder.rb', line 29

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
26
27
# 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(
      ::VIM.evaluate("bufname(#{MRU.last})")
    ) == matches.first
    matches[1..-1] + [matches.first]
  else
    matches
  end
end