1
0
mirror of https://github.com/gryf/pythonhelper.git synced 2025-12-18 12:00:27 +01:00

Bugfix and move plugin to python specific ftplugin

Move to python specific plugin (ftplugin),
Fixed bug regarding empty buffer.
This commit is contained in:
2016-05-25 08:27:36 +02:00
parent 81a638762b
commit c41a450990
4 changed files with 23 additions and 3 deletions

View File

@@ -151,7 +151,11 @@ class PythonHelper(object):
line_number = vim.current.window.cursor[0] - 1
while True:
try:
line = vim.current.buffer[line_number]
except IndexError:
return None
line_indent = len(RE_INDENT.match(line).group(1))
if line.strip():
break

View File

@@ -17,8 +17,7 @@ class Window(object):
class Current(object):
def __init__(self):
with open('test_py_example.py') as fobj:
self.buffer = fobj.read().split('\n')
self.buffer = []
self.window = Window()
@@ -26,6 +25,9 @@ class MockVim(object):
current = Current()
command = Command()
with open('test_py_example.py') as fobj:
BUFFER = fobj.read().split('\n')
sys.modules['vim'] = vim = MockVim
@@ -33,8 +35,22 @@ sys.modules['vim'] = vim = MockVim
import pythonhelper
class TestTagsHelperWithEmptyBuffer(unittest.TestCase):
def setUp(self):
vim.current.buffer = []
def test_get_tag(self):
vim.current.window.cursor = (1, 1)
tag = pythonhelper.PythonHelper._get_tag(1, 2)
self.assertIsNone(tag)
class TestTagsHelper(unittest.TestCase):
def setUp(self):
vim.current.buffer = BUFFER
def test_import(self):
vim.current.window.cursor = (1, 1)
tag = pythonhelper.PythonHelper._get_tag(1, 2)