Permalink
Browse files

Added ability to flush cache and refresh while match listing is open

See:

  https://wincent.com/issues/1942

Signed-off-by: Wincent Colaiuta <win@wincent.com>
  • Loading branch information...
1 parent ca5566e commit 341d0e54822c72f32be1664f8bedc0cdbd2f87c0 @wincent committed Apr 29, 2012
Showing with 37 additions and 16 deletions.
  1. +12 −4 doc/command-t.txt
  2. +4 −0 plugin/command-t.vim
  3. +16 −7 ruby/command-t/controller.rb
  4. +0 −4 ruby/command-t/finder.rb
  5. +5 −1 ruby/command-t/finder/file_finder.rb
View
@@ -308,6 +308,7 @@ has focus:
<C-k> select previous file in the file listing
<C-p> select previous file in the file listing
<Up> select previous file in the file listing
+ <C-f> flush the cache (see |:CommandTFlush| for details)
<C-c> cancel (dismisses file listing)
The following is also available on terminals which support it:
@@ -353,10 +354,12 @@ COMMANDS *command-t-commands*
*:CommandTFlush*
|:CommandTFlush|Instructs the plug-in to flush its path cache, causing
the directory to be rescanned for new or deleted paths
- the next time the file window is shown. In addition, all
- configuration settings are re-evaluated, causing any
- changes made to settings via the |:let| command to be picked
- up.
+ the next time the file window is shown (pressing <C-f> when
+ a match listing is visible flushes the cache immediately; this
+ mapping is configurable via the |g:CommandTRefreshMap|
+ setting). In addition, all configuration settings are
+ re-evaluated, causing any changes made to settings via the
+ |:let| command to be picked up.
MAPPINGS *command-t-mappings*
@@ -565,6 +568,9 @@ Following is a list of all map settings and their defaults:
*g:CommandTClearMap*
|g:CommandTClearMap| <C-u>
+ *g:CommandTRefreshMap*
+ |g:CommandTRefreshMap| <C-f>
+
*g:CommandTCursorLeftMap*
|g:CommandTCursorLeftMap| <Left>
<C-h>
@@ -729,6 +735,8 @@ HISTORY *command-t-history*
- highlight (by underlining) matched characters in the match listing (requires
Vim to have been compiled with the +conceal feature, which is available in
Vim 7.3 or later; patch from Steven Moazami)
+- added the ability to flush the cache while the match window is open using
+ <C-f>
1.3.1 (18 December 2011)
@@ -120,6 +120,10 @@ function CommandTAcceptSelectionVSplit()
ruby $command_t.accept_selection :command => 'vs'
endfunction
+function CommandTRefresh()
+ ruby $command_t.refresh
+endfunction
+
function CommandTToggleFocus()
ruby $command_t.toggle_focus
endfunction
@@ -79,6 +79,12 @@ def hide
end
end
+ def refresh
+ return unless @active_finder && @active_finder.respond_to?(:flush)
+ @active_finder.flush
+ list_matches
+ end
+
def flush
@max_height = nil
@min_height = nil
@@ -279,21 +285,24 @@ def register_for_key_presses
end
# "special" keys (overridable by settings)
- { 'Backspace' => '<BS>',
- 'Delete' => '<Del>',
+ {
'AcceptSelection' => '<CR>',
'AcceptSelectionSplit' => ['<C-CR>', '<C-s>'],
'AcceptSelectionTab' => '<C-t>',
'AcceptSelectionVSplit' => '<C-v>',
- 'ToggleFocus' => '<Tab>',
+ 'Backspace' => '<BS>',
'Cancel' => ['<C-c>', '<Esc>'],
- 'SelectNext' => ['<C-n>', '<C-j>', '<Down>'],
- 'SelectPrev' => ['<C-p>', '<C-k>', '<Up>'],
'Clear' => '<C-u>',
+ 'CursorEnd' => '<C-e>',
'CursorLeft' => ['<Left>', '<C-h>'],
'CursorRight' => ['<Right>', '<C-l>'],
- 'CursorEnd' => '<C-e>',
- 'CursorStart' => '<C-a>' }.each do |key, value|
+ 'CursorStart' => '<C-a>',
+ 'Delete' => '<Del>',
+ 'Refresh' => '<C-f>',
+ 'SelectNext' => ['<C-n>', '<C-j>', '<Down>'],
+ 'SelectPrev' => ['<C-p>', '<C-k>', '<Up>'],
+ 'ToggleFocus' => '<Tab>',
+ }.each do |key, value|
if override = get_list_or_string("g:CommandT#{key}Map")
Array(override).each do |mapping|
map mapping, key
@@ -43,10 +43,6 @@ def sorted_matches_for str, options = {}
@matcher.sorted_matches_for str, options
end
- def flush
- @scanner.flush
- end
-
def open_selection command, selection, options = {}
::VIM::command "silent #{command} #{selection}"
end
@@ -1,4 +1,4 @@
-# Copyright 2010-2011 Wincent Colaiuta. All rights reserved.
+# Copyright 2010-2012 Wincent Colaiuta. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -31,5 +31,9 @@ def initialize path = Dir.pwd, options = {}
@scanner = FileScanner.new path, options
@matcher = Matcher.new @scanner, options
end
+
+ def flush
+ @scanner.flush
+ end
end # class FileFinder
end # CommandT

0 comments on commit 341d0e5

Please sign in to comment.