Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions spyder_vim/spyder/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,11 @@ def G(self, repeat=-1):
else:
self.gg(repeat)

def gd(self, repeat=-1):
"""Go to definition."""
self._widget.editor().go_to_definition_from_cursor()
self._widget.commandline.setFocus()

def gg(self, repeat=1):
"""Go to the first position of the first line."""
editor = self._widget.editor()
Expand Down
25 changes: 25 additions & 0 deletions tests/spyder-vim/class_for_testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""DocString."""


class ClassForTesting:
"""Docstring."""

def __init__(self):
"""
Imperative description.

Args:
NA

"""
self.a = "eh"

def test_func(self, arg):
"""
Imperative description.

Args:
arg

"""
self.a = arg
14 changes: 14 additions & 0 deletions tests/spyder-vim/script_for_testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""Imperative docstring."""

from class_for_testing import ClassForTesting


def main():
"""Imperative docstring."""
cft = ClassForTesting()

cft.test_func("b")


if __name__ == "__main__":
main()
9 changes: 9 additions & 0 deletions tests/spyder-vim/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2105,3 +2105,12 @@ def test_lessless_command(vim_bot, text, command_list, result, cursor_pos):
assert editor.toPlainText() == result
assert editor.textCursor().position() == cursor_pos

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