@@ -43,15 +43,17 @@ def unwrap(obj: Value) -> lldb.SBValue:
4343
4444def create_webview (html : Optional [str ] = None , title : Optional [str ] = None , view_column : Optional [int ] = None ,
4545 preserve_focus : bool = False , enable_find_widget : bool = False ,
46- retain_context_when_hidden : bool = False , enable_scripts : bool = False ):
46+ retain_context_when_hidden : bool = False , enable_scripts : bool = False ,
47+ preserve_orphaned : bool = False ):
4748 '''Create a [webview panel](https://code.visualstudio.com/api/references/vscode-api#WebviewPanel).
4849 html: HTML content to display in the webview. May be later replaced via Webview.set_html().
4950 title: Panel title.
5051 view_column: Column in which to show the webview.
5152 preserve_focus: Whether to preserve focus in the current editor when revealing the webview.
52- enable_find_widget: Controls if the find widget is enabled in the panel.
53- retain_context_when_hidden: Controls if the webview panel retains its context when it is hidden.
54- enable_scripts: Controls if scripts are enabled in the webview.
53+ enable_find_widget: Controls whether the find widget is enabled in the panel.
54+ retain_context_when_hidden: Controls whether the webview panel retains its context when hidden.
55+ enable_scripts: Controls whether scripts are enabled in the webview.
56+ preserve_orphaned: Preserve webview panel after the end of the debug session.
5557 '''
5658 debugger_id = lldb .debugger .GetID ()
5759 webview = Webview (debugger_id )
@@ -64,17 +66,24 @@ def create_webview(html: Optional[str] = None, title: Optional[str] = None, view
6466 preserveFocus = preserve_focus ,
6567 enableFindWidget = enable_find_widget ,
6668 retainContextWhenHidden = retain_context_when_hidden ,
67- enableScripts = enable_scripts
69+ enableScripts = enable_scripts ,
70+ preserveOrphaned = preserve_orphaned ,
6871 )
6972 )
7073 return webview
7174
7275
73- def display_html (html : str , title : Optional [str ] = None , position : Optional [int ] = None , reveal : bool = False ):
76+ def debugger_message (output : str , category : str = 'console' ):
77+ interface .fire_event (lldb .debugger .GetID (), dict (type = 'DebuggerMessage' , output = output , category = category ))
78+
79+
80+ def display_html (html : str , title : Optional [str ] = None , position : Optional [int ] = None , reveal : bool = False ,
81+ preserve_orphaned : bool = True ):
7482 '''Display HTML content in a webview panel.
7583 display_html is **deprecated**, use create_webview instead.
7684 '''
77- global html_webview
85+ inst_dict = interface .get_instance_dict (lldb .debugger )
86+ html_webview = inst_dict .get ('html_webview' )
7887 if html_webview is None :
7988 warnings .warn ("display_html is deprecated, use create_webview instead" , DeprecationWarning )
8089
@@ -83,27 +92,25 @@ def display_html(html: str, title: Optional[str] = None, position: Optional[int]
8392 title = title ,
8493 view_column = position ,
8594 preserve_focus = not reveal ,
86- enable_scripts = True
95+ enable_scripts = True ,
96+ preserve_orphaned = preserve_orphaned ,
8797 )
8898
8999 def on_message (message ):
90100 if message ['command' ] == 'execute' :
91101 lldb .debugger .HandleCommand (message ['text' ])
92102
93103 def on_disposed (message ):
94- global html_webview
95- html_webview = None
104+ del globals ()['html_webview' ]
96105
97106 html_webview .on_did_receive_message .add (on_message )
98107 html_webview .on_did_dispose .add (on_disposed )
108+ inst_dict ['html_webview' ] = html_webview
99109 else :
100110 html_webview .set_html (html )
101111 if reveal :
102112 html_webview .reveal (view_column = position )
103113
104114
105- html_webview = None
106-
107-
108115def __lldb_init_module (debugger , internal_dict ): # pyright: ignore
109116 debugger .HandleCommand ('command script add -c debugger.DebugInfoCommand debug_info' )
0 commit comments