Skip to content

Commit

Permalink
fix: fallback to scanning through doc in sig
Browse files Browse the repository at this point in the history
line numbers may change during editing, and often a signature lookup
happens on a new line, so the line number no longer lines up with the
right definition. when this happens, we fall back to scanning through
the doc. if this becomes a performance hotspot it may be worth
optimizing where we start scanning from, and wrap-around
  • Loading branch information
z80dev committed Aug 9, 2024
1 parent 5917c85 commit f8cf609
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions vyper_lsp/analyzer/AstAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ def signature_help(
expression = get_expression_at_cursor(
current_line, params.position.character - 1
)
# TODO: Implement checking external functions, module functions, and interfaces
fn_name = get_internal_fn_name_at_cursor(
current_line, params.position.character - 1
)

# this returns for all external functions
# TODO: Implement checking interfaces
if not expression.startswith("self."):
return None

Expand All @@ -85,6 +88,15 @@ def signature_help(
fn_name = node.name
parameters = []
line = doc.lines[node.lineno - 1]

decl_str = f"def {fn_name}("
search_start_line_no = 0

while not line.startswith(decl_str):
line = doc.lines[search_start_line_no]
search_start_line_no += 1


fn_label = line.removeprefix("def ").removesuffix(":\n")

for arg in node.args.args:
Expand Down

0 comments on commit f8cf609

Please sign in to comment.