Skip to content

Commit

Permalink
Don't go to definition of builtin modules (#687)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwickham authored and gatesn committed Nov 1, 2019
1 parent 1ea46ae commit ac79cef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions pyls/plugins/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
2 changes: 1 addition & 1 deletion test/plugins/test_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit ac79cef

Please sign in to comment.