Skip to content

Commit

Permalink
Improve converter_uniq_word
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed May 22, 2016
1 parent a026352 commit 5fd81fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion autoload/unite/filters.vim
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@ function! unite#filters#uniq(list) abort "{{{
if !has_key(dict, key)
let word = key
elseif dict[key] != '/' && dict[key] != ''
let word = '.../' . word[len(dict[key]):]
let rest = split(word[len(dict[key]):], '/', 1)
let word = '.../' . (len(rest) > 3 ?
\ (rest[0] . '/.../' . rest[-2] . '/' . rest[-1]) :
\ join(rest, '/'))
endif
endif
call add(uniq, word)
Expand Down
3 changes: 3 additions & 0 deletions test/converter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ function! s:suite.uniq() abort
call s:assert.equals(unite#filters#uniq(
\ [ '/foo/baz/bar/', '/foo/bar/bar/' ]),
\ ['.../baz/bar/', '.../bar/bar/'])
call s:assert.equals(unite#filters#uniq(
\ [ '/foo/bar/bar', '/foo/bar/bar' ]),
\ ['.../bar', '.../bar'])
endfunction

" vim:foldmethod=marker:fen:

0 comments on commit 5fd81fe

Please sign in to comment.