Skip to content

Commit 4f95a48

Browse files
committed
for . Maybe the tests will work one day.
1 parent 1eecb52 commit 4f95a48

4 files changed

Lines changed: 53 additions & 0 deletions

File tree

spyder_vim/spyder/widgets.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,11 @@ def G(self, repeat=-1):
572572
else:
573573
self.gg(repeat)
574574

575+
def gd(self, repeat=-1):
576+
"""Go to definition."""
577+
self._widget.editor().go_to_definition_from_cursor()
578+
self._widget.commandline.setFocus()
579+
575580
def gg(self, repeat=1):
576581
"""Go to the first position of the first line."""
577582
editor = self._widget.editor()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""DocString."""
2+
3+
4+
class ClassForTesting:
5+
"""Docstring."""
6+
7+
def __init__(self):
8+
"""
9+
Imperative description.
10+
11+
Args:
12+
NA
13+
14+
"""
15+
self.a = "eh"
16+
17+
def test_func(self, arg):
18+
"""
19+
Imperative description.
20+
21+
Args:
22+
arg
23+
24+
"""
25+
self.a = arg
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""Imperative docstring."""
2+
3+
from class_for_testing import ClassForTesting
4+
5+
6+
def main():
7+
"""Imperative docstring."""
8+
cft = ClassForTesting()
9+
10+
cft.test_func("b")
11+
12+
13+
if __name__ == "__main__":
14+
main()

tests/spyder-vim/test_widgets.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,3 +2105,12 @@ def test_lessless_command(vim_bot, text, command_list, result, cursor_pos):
21052105
assert editor.toPlainText() == result
21062106
assert editor.textCursor().position() == cursor_pos
21072107

2108+
def test_gd_command(vim_bot):
2109+
"""Go to the spot where ClassForTesting.fun` is defined."""
2110+
main, editor_stack, editor, vim, qtbot = vim_bot
2111+
editor.set_text_from_file(osp.join(LOCATION, 'script_for_testing.py'))
2112+
editor.find("test_func")
2113+
cmd_line = vim.get_focus_widget()
2114+
qtbot.keyClicks(cmd_line, "gd")
2115+
new_line, new_col = editor.get_cursor_line_column()
2116+
assert new_col == 9 and new_line == 17

0 commit comments

Comments
 (0)