@@ -585,10 +585,10 @@ def m_text_document__code_lens(self, textDocument=None, **_kwargs):
585
585
def m_text_document__completion (self , textDocument = None , position = None , ** _kwargs ):
586
586
return self .completions (textDocument ['uri' ], position )
587
587
588
- def m_notebook_document__definition (self , cellDocument = None , position = None , ** _kwargs ):
588
+ def _cell_document__definition (self , cellDocument = None , position = None , ** _kwargs ):
589
589
# First, we create a temp TextDocument that represents the whole notebook
590
590
# contents. We'll use this to send to the hook.
591
- workspace = self ._match_uri_to_workspace (notebookDocument [ 'uri' ] )
591
+ workspace = self ._match_uri_to_workspace (cellDocument . notebook_uri )
592
592
593
593
random_uri = str (uuid .uuid4 ())
594
594
# cell_list helps us map the diagnostics back to the correct cell later.
@@ -609,6 +609,9 @@ def m_notebook_document__definition(self, cellDocument=None, position=None, **_k
609
609
'source' : cell_document .source
610
610
}
611
611
612
+ if position is not None and cell_uri == cellDocument .uri :
613
+ position ['line' ] += offset
614
+
612
615
cell_list .append (data )
613
616
if offset == 0 :
614
617
total_source = cell_document .source
@@ -619,11 +622,10 @@ def m_notebook_document__definition(self, cellDocument=None, position=None, **_k
619
622
620
623
# TODO: make a workspace temp document context manager that yields the random uri and cleans up afterwards
621
624
workspace .put_document (random_uri , total_source )
622
-
625
+ log . info ( f'Making new document { random_uri } ' )
623
626
try :
624
- # TODO: adjust position to temp document
625
- # position =
626
627
definitions = self .definitions (random_uri , position )
628
+ log .info (f'Got definitions: { definitions } ' )
627
629
628
630
# {
629
631
# 'uri': uris.uri_with(document.uri, path=str(d.module_path)),
@@ -632,19 +634,21 @@ def m_notebook_document__definition(self, cellDocument=None, position=None, **_k
632
634
# 'end': {'line': d.line - 1, 'character': d.column + len(d.name)},
633
635
# }
634
636
# }
637
+ print (definitions )
635
638
for definition in definitions :
636
639
if definition ['uri' ] == random_uri :
637
640
# find what cell the start is in
638
641
# make sure the end is inside the cell's line_end
639
642
# subtract that cell's line_start from both definition start and end
640
643
pass
644
+ return definitions
641
645
finally :
642
646
workspace .rm_document (random_uri )
643
647
644
648
def m_text_document__definition (self , textDocument = None , position = None , ** _kwargs ):
645
649
if isinstance (textDocument , Cell ):
646
650
# actually, test to see if the document is a cell document
647
- return self .m_notebook_document__definition (textDocument , position , ** _kwargs )
651
+ return self ._cell_document__definition (textDocument , position , ** _kwargs )
648
652
return self .definitions (textDocument ['uri' ], position )
649
653
650
654
def m_text_document__document_highlight (self , textDocument = None , position = None , ** _kwargs ):
0 commit comments