Skip to content

Commit 8430a70

Browse files
committed
Boolean return for rails#buffer().type_name('foo')
1 parent 6495d8f commit 8430a70

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

autoload/rails.vim

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -713,21 +713,25 @@ function! s:readable_calculate_file_type() dict abort
713713
return r
714714
endfunction
715715

716-
function! s:buffer_type_name() dict abort
717-
let var = getbufvar(self._number,'rails_cached_file_type')
718-
if var == '-'
719-
return ''
720-
elseif var != ''
721-
return var
722-
else
716+
function! s:buffer_type_name(...) dict abort
717+
let type = getbufvar(self._number,'rails_cached_file_type')
718+
if type == ''
723719
let type = self.calculate_file_type()
724-
return type == '-' ? '' : type
725720
endif
721+
return call('s:match_type',[type == '-' ? '' : type] + a:000)
726722
endfunction
727723

728724
function! s:readable_type_name() dict abort
729725
let type = self.calculate_file_type()
730-
return type == '-' ? '' : type
726+
return call('s:match_type',[type == '-' ? '' : type] + a:000)
727+
endfunction
728+
729+
function! s:match_type(type,...)
730+
if a:0
731+
return !empty(filter(copy(a:000),'a:type =~# "^".v:val."\\>"'))
732+
else
733+
return a:type
734+
endif
731735
endfunction
732736

733737
function! s:app_environments() dict

0 commit comments

Comments
 (0)