Added line_count segment for vim.
Returns total number of lines in current buffer. Addresses #556
This commit is contained in:
parent
da6667bd14
commit
f615d85172
|
@ -10,6 +10,7 @@
|
|||
"file_directory": "information:additional",
|
||||
"file_name_empty": "file_directory",
|
||||
"line_percent": "information:additional",
|
||||
"line_count": "line_current",
|
||||
"position": "information:additional"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -334,6 +334,12 @@ def line_current(pl, segment_info):
|
|||
return str(segment_info['window'].cursor[0])
|
||||
|
||||
|
||||
@requires_segment_info
|
||||
def line_count(pl, segment_info):
|
||||
'''Return the line count of the current buffer.'''
|
||||
return str(len(segment_info['buffer']))
|
||||
|
||||
|
||||
@requires_segment_info
|
||||
def col_current(pl, segment_info):
|
||||
'''Return the current cursor column.
|
||||
|
|
|
@ -687,6 +687,17 @@ class TestVim(TestCase):
|
|||
finally:
|
||||
vim_module._bw(segment_info['bufnr'])
|
||||
|
||||
def test_line_count(self):
|
||||
pl = Pl()
|
||||
segment_info = vim_module._get_segment_info()
|
||||
segment_info['buffer'][0:-1] = [str(i) for i in range(99)]
|
||||
try:
|
||||
self.assertEqual(vim.line_count(pl=pl, segment_info=segment_info), '100')
|
||||
vim_module._set_cursor(50, 0)
|
||||
self.assertEqual(vim.line_count(pl=pl, segment_info=segment_info), '100')
|
||||
finally:
|
||||
vim_module._bw(segment_info['bufnr'])
|
||||
|
||||
def test_position(self):
|
||||
pl = Pl()
|
||||
segment_info = vim_module._get_segment_info()
|
||||
|
|
Loading…
Reference in New Issue