Skip to content

Commit 41bf833

Browse files
committed
Implement rails#buffer().number()
1 parent 8430a70 commit 41bf833

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

autoload/rails.vim

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,9 @@ endfunction
413413

414414
function! s:buffer_getline(...) dict abort
415415
if a:0 == 1
416-
return get(call('getbufline',[self._number]+a:000),0,'')
416+
return get(call('getbufline',[self.number()]+a:000),0,'')
417417
else
418-
return call('getbufline',[self._number]+a:000)
418+
return call('getbufline',[self.number()]+a:000)
419419
endif
420420
endfunction
421421

@@ -460,11 +460,11 @@ function! s:debug(str)
460460
endfunction
461461

462462
function! s:buffer_getvar(varname) dict abort
463-
return getbufvar(self._number,a:varname)
463+
return getbufvar(self.number(),a:varname)
464464
endfunction
465465

466466
function! s:buffer_setvar(varname, val) dict abort
467-
return setbufvar(self._number,a:varname,a:val)
467+
return setbufvar(self.number(),a:varname,a:val)
468468
endfunction
469469

470470
call s:add_methods('buffer',['getvar','setvar'])
@@ -528,7 +528,7 @@ function! rails#app(...)
528528
endfunction
529529

530530
function! rails#buffer(...)
531-
return extend(extend({'_number': bufnr(a:0 ? a:1 : '%')},s:buffer_prototype,'keep'),s:readable_prototype,'keep')
531+
return extend(extend({'#': bufnr(a:0 ? a:1 : '%')},s:buffer_prototype,'keep'),s:readable_prototype,'keep')
532532
endif
533533
endfunction
534534

@@ -568,16 +568,17 @@ function! s:file_name() dict abort
568568
return self._name
569569
endfunction
570570

571+
function! s:buffer_number() dict abort
572+
return self['#']
573+
endfunction
574+
571575
function! s:buffer_path() dict abort
572-
return s:gsub(fnamemodify(bufname(self._number),':p'),'\\ @!','/')
576+
return s:gsub(fnamemodify(bufname(self.number()),':p'),'\\ @!','/')
573577
endfunction
574578

575579
function! s:buffer_name() dict abort
576580
let app = self.app()
577-
if getbufvar(self._number,'rails_file_type') != ''
578-
return getbufvar(self.number,'rails_file_type')
579-
endif
580-
let f = s:gsub(fnamemodify(bufname(self._number),':p'),'\\ @!','/')
581+
let f = s:gsub(fnamemodify(bufname(self.number()),':p'),'\\ @!','/')
581582
let f = s:sub(f,'/$','')
582583
let sep = matchstr(f,'^[^\\/]\{3,\}\zs[\\/]')
583584
if sep != ""
@@ -714,7 +715,7 @@ function! s:readable_calculate_file_type() dict abort
714715
endfunction
715716

716717
function! s:buffer_type_name(...) dict abort
717-
let type = getbufvar(self._number,'rails_cached_file_type')
718+
let type = getbufvar(self.number(),'rails_cached_file_type')
718719
if type == ''
719720
let type = self.calculate_file_type()
720721
endif
@@ -773,7 +774,7 @@ endfunction
773774

774775
call s:add_methods('app',['default_locale','environments','file','has','test_suites'])
775776
call s:add_methods('file',['path','name','lines','getline'])
776-
call s:add_methods('buffer',['app','path','name','lines','getline','type_name'])
777+
call s:add_methods('buffer',['app','number','path','name','lines','getline','type_name'])
777778
call s:add_methods('readable',['app','calculate_file_type','type_name','line_count'])
778779

779780
" }}}1

0 commit comments

Comments
 (0)