@@ -593,7 +593,6 @@ def _cell_document__definition(self, cellDocument=None, position=None, **_kwargs
593
593
if notebookDocument is None :
594
594
raise ValueError ("Invalid notebook document" )
595
595
596
- random_uri = str (uuid .uuid4 ())
597
596
# cell_list helps us map the diagnostics back to the correct cell later.
598
597
cell_list : List [Dict [str , Any ]] = []
599
598
@@ -623,21 +622,8 @@ def _cell_document__definition(self, cellDocument=None, position=None, **_kwargs
623
622
624
623
offset += num_lines
625
624
626
- # TODO: make a workspace temp document context manager that yields the random uri and cleans up afterwards
627
- workspace .put_document (random_uri , total_source )
628
- log .info (f'Making new document { random_uri } ' )
629
- try :
625
+ with workspace .temp_document (total_source ) as random_uri :
630
626
definitions = self .definitions (random_uri , position )
631
- log .info (f'Got definitions: { definitions } ' )
632
-
633
- # {
634
- # 'uri': uris.uri_with(document.uri, path=str(d.module_path)),
635
- # 'range': {
636
- # 'start': {'line': d.line - 1, 'character': d.column},
637
- # 'end': {'line': d.line - 1, 'character': d.column + len(d.name)},
638
- # }
639
- # }
640
- print (definitions )
641
627
for definition in definitions :
642
628
# TODO: a better test for if a definition is the random_uri
643
629
if random_uri in definition ['uri' ]:
@@ -650,8 +636,6 @@ def _cell_document__definition(self, cellDocument=None, position=None, **_kwargs
650
636
definition ['range' ]['start' ]['line' ] -= cell ['line_start' ]
651
637
definition ['range' ]['end' ]['line' ] -= cell ['line_start' ]
652
638
return definitions
653
- finally :
654
- workspace .rm_document (random_uri )
655
639
656
640
def m_text_document__definition (self , textDocument = None , position = None , ** _kwargs ):
657
641
# textDocument here is just a dict with a uri
0 commit comments