@@ -29,6 +29,9 @@ def __getattr__(self, name):
2929 if child .name == "." + name :
3030 return child
3131
32+ def restore_text (self , text ):
33+ return text [self .start :self .end ]
34+
3235class Named :
3336 """
3437 Parser that assigns name to Node
@@ -411,7 +414,22 @@ def topmost_form(view, point):
411414
412415 parsed = parse_tree (view )
413416 if node := search (parsed , point , max_depth = 1 ):
414- if body := node .body :
417+ # look inside ;; ...
418+ if node .name == "comment" :
419+ comment_start = node .start
420+ comment_text = node .restore_text (view .substr (sublime .Region (0 , view .size ())))
421+ comment_inside_start = re .match (r'^[; ]*' , comment_text ).end ()
422+ delta = comment_start + comment_inside_start
423+ comment_inside_text = comment_text [comment_inside_start :]
424+ parsed2 = parse (comment_inside_text )
425+ if node2 := search (parsed2 , point - delta , max_depth = 1 ):
426+ return sublime .Region (delta + node2 .start , delta + node2 .end )
427+ # look inside #_...
428+ elif node .name == "discard" and node .body .children [0 ] and point >= node .body .start :
429+ node2 = node .body .children [0 ]
430+ return sublime .Region (node2 .start , node2 .end )
431+ # look inside (comment ...)
432+ elif body := node .body :
415433 if body .children :
416434 first_form = body .children [0 ]
417435 if first_form .name == "token" and first_form .text == "comment" and point > first_form .end :
0 commit comments