@@ -8,15 +8,24 @@ import { type RegisterLocalProcessExtensionResult } from '@codingame/monaco-vsco
88import React from 'react' ;
99import ReactDOM from 'react-dom/client' ;
1010import { MonacoEditorReactComp } from '@typefox/monaco-editor-react' ;
11- import { MonacoEditorLanguageClientWrapper , type TextChanges } from 'monaco-editor-wrapper' ;
11+ import { MonacoEditorLanguageClientWrapper , type TextContents } from 'monaco-editor-wrapper' ;
1212import { createWrapperConfig } from './config.js' ;
1313import { confiugureDebugging } from '../../debugger/client/debugger.js' ;
1414
1515export const runPythonReact = async ( ) => {
1616 const appConfig = createWrapperConfig ( ) ;
17-
18- const onTextChanged = ( textChanges : TextContents ) => {
19- console . log ( `text: ${ textChanges . modified } \ntextOriginal: ${ textChanges . original } ` ) ;
17+
18+ const onLoad = async ( wrapper : MonacoEditorLanguageClientWrapper ) => {
19+ const result = wrapper . getExtensionRegisterResult ( 'mlc-python-example' ) as RegisterLocalProcessExtensionResult ;
20+ result . setAsDefaultApi ( ) ;
21+
22+ const initResult = wrapper . getExtensionRegisterResult ( 'debugger-py-client' ) as RegisterLocalProcessExtensionResult | undefined ;
23+ if ( initResult !== undefined ) {
24+ confiugureDebugging ( await initResult . getApi ( ) , appConfig . configParams ) ;
25+ }
26+
27+ await vscode . commands . executeCommand ( 'workbench.view.explorer' ) ;
28+ await vscode . window . showTextDocument ( appConfig . configParams . files . get ( 'hello2.py' ) ! . uri ) ;
2029 } ;
2130
2231 const root = ReactDOM . createRoot ( document . getElementById ( 'react-root' ) ! ) ;
@@ -27,19 +36,7 @@ export const runPythonReact = async () => {
2736 < MonacoEditorReactComp
2837 wrapperConfig = { appConfig . wrapperConfig }
2938 style = { { 'height' : '100%' } }
30- onTextChanged = { onTextChanged }
31- onLoad = { async ( wrapper : MonacoEditorLanguageClientWrapper ) => {
32- const result = wrapper . getExtensionRegisterResult ( 'mlc-python-example' ) as RegisterLocalProcessExtensionResult ;
33- result . setAsDefaultApi ( ) ;
34-
35- const initResult = wrapper . getExtensionRegisterResult ( 'debugger-py-client' ) as RegisterLocalProcessExtensionResult | undefined ;
36- if ( initResult !== undefined ) {
37- confiugureDebugging ( await initResult . getApi ( ) , appConfig . configParams ) ;
38- }
39-
40- await vscode . commands . executeCommand ( 'workbench.view.explorer' ) ;
41- await vscode . window . showTextDocument ( appConfig . configParams . files . get ( 'hello2.py' ) ! . uri ) ;
42- } }
39+ onLoad = { onLoad }
4340 onError = { ( e ) => {
4441 console . error ( e ) ;
4542 } } />
0 commit comments