diff --git a/pyls/plugins/definition.py b/pyls/plugins/definition.py index 69109afd..8ec3b1ad 100644 --- a/pyls/plugins/definition.py +++ b/pyls/plugins/definition.py @@ -20,6 +20,14 @@ def pyls_definitions(config, document, position): 'end': {'line': d.line - 1, 'character': d.column + len(d.name)}, } } - for d in definitions - if d.is_definition() and d.line is not None and d.column is not None and d.module_path is not None + for d in definitions if d.is_definition() and _not_internal_definition(d) ] + + +def _not_internal_definition(definition): + return ( + definition.line is not None and + definition.column is not None and + definition.module_path is not None and + not definition.in_builtin_module() + ) diff --git a/test/plugins/test_definitions.py b/test/plugins/test_definitions.py index 3faa7cfb..e2db9c6f 100644 --- a/test/plugins/test_definitions.py +++ b/test/plugins/test_definitions.py @@ -40,7 +40,7 @@ def test_builtin_definition(config): # No go-to def for builtins doc = Document(DOC_URI, DOC) - assert len(pyls_definitions(config, doc, cursor_pos)) == 1 + assert not pyls_definitions(config, doc, cursor_pos) def test_assignment(config):