Created
April 13, 2009 05:45
-
-
Save hotchpotch/94299 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*** fuzzyfinder.vim.org 2009-04-13 14:42:27.000000000 +0900 | |
--- fuzzyfinder.vim 2009-03-12 11:30:02.000000000 +0900 | |
*************** | |
*** 569,574 **** | |
--- 569,581 ---- | |
return a:str[:(a:len - len(s:ABBR_TRIM_MARK) - 1)] . s:ABBR_TRIM_MARK | |
endfunction | |
+ function! s:TrimFirst(str, len) | |
+ if a:len <= 0 || len(a:str) <= a:len | |
+ return a:str | |
+ endif | |
+ return s:ABBR_TRIM_MARK . a:str[(len(a:str)-a:len):(len(a:str)-1)] | |
+ endfunction | |
+ | |
" takes suffix numer. if no digits, returns -1 | |
function! s:SuffixNumber(str) | |
let s = matchstr(a:str, '\d\+$') | |
*************** | |
*** 821,827 **** | |
endfunction | |
function! s:SetFormattedAbbr(item, key, trim_len) | |
! let a:item.abbr = s:TrimLast(printf('%3d: %s', a:item.index, a:item[a:key]), a:trim_len) | |
return a:item | |
endfunction | |
--- 828,835 ---- | |
endfunction | |
function! s:SetFormattedAbbr(item, key, trim_len) | |
! " let a:item.abbr = s:TrimLast(printf('%3d: %s', a:item.index, a:item[a:key]), a:trim_len) | |
! let a:item.abbr = s:TrimFirst(printf('%3d: %s', a:item.index, a:item[a:key]), a:trim_len) | |
return a:item | |
endfunction | |
*************** | |
*** 1090,1098 **** | |
" partial: 'str' -> {'base':'str', 'wi':'*str*', 're':'\V\.\*str\.\*'} | |
function! g:FuzzyFinderMode.Base.make_pattern(base) | |
if self.partial_matching | |
! let wi = (a:base !~ '^[*?]' ? '*' : '') . a:base . | |
! \ (a:base =~ '[^*?]$' ? '*' : '') | |
! let re = s:ConvertWildcardToRegexp(wi) | |
return { 'base': a:base, 'wi':wi, 're': re } | |
else | |
let wi = '' | |
--- 1098,1121 ---- | |
" partial: 'str' -> {'base':'str', 'wi':'*str*', 're':'\V\.\*str\.\*'} | |
function! g:FuzzyFinderMode.Base.make_pattern(base) | |
if self.partial_matching | |
! let words = split(a:base, '\v\s+') | |
! if len(words) >= 2 | |
! let wi1 = (words[0] !~ '^[*?]' ? '*' : '') . words[0] . | |
! \ (words[0] =~ '[^*?]$' ? '*' : '') | |
! let wi2 = (words[1] !~ '^[*?]' ? '*' : '') . words[1] . | |
! \ (words[1] =~ '[^*?]$' ? '*' : '') | |
! let wi1 = substitute(s:ConvertWildcardToRegexp(wi1), '^\\V', '', '') | |
! let wi2 = substitute(s:ConvertWildcardToRegexp(wi2), '^\\V', '', '') | |
! let wi = 'FIXME' | |
! let re = '\V'.'\('.wi1.wi2.'\)\|\('.wi2.wi1.'\)' | |
! elseif len(words) == 1 | |
! let wi = (words[0] !~ '^[*?]' ? '*' : '') . words[0] . | |
! \ (words[0] =~ '[^*?]$' ? '*' : '') | |
! let re = s:ConvertWildcardToRegexp(wi) | |
! else | |
! let wi = '' | |
! let re = s:ConvertWildcardToRegexp(wi) | |
! endif | |
return { 'base': a:base, 'wi':wi, 're': re } | |
else | |
let wi = '' | |
*************** | |
*** 1270,1280 **** | |
" OBJECT: g:FuzzyFinderMode.MruFile ------------------------------------- {{{1 | |
let g:FuzzyFinderMode.MruFile = copy(g:FuzzyFinderMode.Base) | |
function! g:FuzzyFinderMode.MruFile.on_complete(base) | |
let patterns = self.make_pattern(a:base) | |
let base_tail = s:SplitPath(a:base).tail | |
let stats = self.get_filtered_stats(a:base) | |
! let result = s:FilterMatching(self.items, 'word', patterns.re, s:SuffixNumber(patterns.base), self.enumerating_limit) | |
return map(result, 's:SetRanks(v:val, s:SplitPath(matchstr(v:val.word, ''^.*[^/\\]'')).tail, base_tail, stats)') | |
endfunction | |
--- 1293,1320 ---- | |
" OBJECT: g:FuzzyFinderMode.MruFile ------------------------------------- {{{1 | |
let g:FuzzyFinderMode.MruFile = copy(g:FuzzyFinderMode.Base) | |
+ function! s:IndexOfMatching(str, words) | |
+ let s = tolower(a:str) | |
+ for word in a:words | |
+ if stridx(s, word) == -1 | |
+ return 0 | |
+ endif | |
+ endfor | |
+ return 1 | |
+ endfunction | |
+ | |
function! g:FuzzyFinderMode.MruFile.on_complete(base) | |
let patterns = self.make_pattern(a:base) | |
let base_tail = s:SplitPath(a:base).tail | |
let stats = self.get_filtered_stats(a:base) | |
! | |
! if 0 | |
! let result = s:FilterMatching(self.items, 'word', patterns.re, s:SuffixNumber(patterns.base), self.enumerating_limit) | |
! else | |
! let words = split(tolower(a:base), ' ') | |
! let result = s:FilterEx(self.items, 's:IndexOfMatching(v:val.word, ' . string(words) . ')', self.enumerating_limit) | |
! endif | |
! | |
return map(result, 's:SetRanks(v:val, s:SplitPath(matchstr(v:val.word, ''^.*[^/\\]'')).tail, base_tail, stats)') | |
endfunction | |
*************** | |
*** 1543,1549 **** | |
function! s:SetLocalOptionsForFuzzyfinder(cwd, complete_func) | |
" countermeasure for auto-cd script | |
! execute ':lcd ' . a:cwd | |
setlocal filetype=fuzzyfinder | |
setlocal bufhidden=delete | |
setlocal buftype=nofile | |
--- 1583,1589 ---- | |
function! s:SetLocalOptionsForFuzzyfinder(cwd, complete_func) | |
" countermeasure for auto-cd script | |
! execute ':lcd ' . escape(a:cwd, ' ') | |
setlocal filetype=fuzzyfinder | |
setlocal bufhidden=delete | |
setlocal buftype=nofile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment