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
8 changes: 8 additions & 0 deletions queries/python/context.scm
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
(class_definition
body: (_) @context.end) @context

; If the function starts with a comment, then use that to end the context.
;
; Note: priority of overlapping rules isn't defined, but this one seems to
; always take precedence over the one below, regardless of the order in which
; they are defined. Maybe the smallest match wins?
(function_definition
(comment) @context.end) @context

(function_definition
body: (_) @context.end) @context

Expand Down
12 changes: 12 additions & 0 deletions test/lang/test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# {{TEST}}
def hello(name: str, age: int) -> None: # {{CONTEXT}}
print(f"Hello {name}! You are {age} years old.")



# {{CURSOR}}

# {{TEST}}
def hello2( # {{CONTEXT}}
name: str, # {{CONTEXT}}
age: int) -> None: # {{CONTEXT}}
# comment




name = 'barry' # {{CURSOR}}
Loading