@@ -57,38 +57,30 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
57
57
} , [ wrapperConfig ] ) ;
58
58
59
59
const initMonaco = useCallback ( async ( ) => {
60
- if ( ! wrapperRef . current . isInitializing ( ) ) {
61
- if ( containerRef . current ) {
62
- wrapperConfig . htmlContainer = containerRef . current ;
63
- await wrapperRef . current . init ( wrapperConfig ) ;
64
- } else {
65
- throw new Error ( 'No htmlContainer found! Aborting...' ) ;
66
- }
60
+ if ( containerRef . current ) {
61
+ wrapperConfig . htmlContainer = containerRef . current ;
62
+ await wrapperRef . current . init ( wrapperConfig ) ;
67
63
} else {
68
- await wrapperRef . current . getInitializingAwait ( ) ;
64
+ throw new Error ( 'No htmlContainer found! Aborting...' ) ;
69
65
}
70
66
} , [ wrapperConfig ] ) ;
71
67
72
68
const startMonaco = useCallback ( async ( ) => {
73
- if ( ! wrapperRef . current . isStarting ( ) ) {
74
- if ( containerRef . current ) {
75
- try {
76
- wrapperRef . current . registerTextChangeCallback ( onTextChanged ) ;
77
- await wrapperRef . current . start ( ) ;
78
- onLoad ?.( wrapperRef . current ) ;
79
- handleOnTextChanged ( ) ;
80
- } catch ( e ) {
81
- if ( onError ) {
82
- onError ( e ) ;
83
- } else {
84
- throw e ;
85
- }
69
+ if ( containerRef . current ) {
70
+ try {
71
+ wrapperRef . current . registerTextChangeCallback ( onTextChanged ) ;
72
+ await wrapperRef . current . start ( ) ;
73
+ onLoad ?.( wrapperRef . current ) ;
74
+ handleOnTextChanged ( ) ;
75
+ } catch ( e ) {
76
+ if ( onError ) {
77
+ onError ( e ) ;
78
+ } else {
79
+ throw e ;
86
80
}
87
- } else {
88
- throw new Error ( 'No htmlContainer found! Aborting...' ) ;
89
81
}
90
82
} else {
91
- await wrapperRef . current . getStartingAwait ( ) ;
83
+ throw new Error ( 'No htmlContainer found! Aborting...' ) ;
92
84
}
93
85
} , [ onError , onLoad , onTextChanged ] ) ;
94
86
@@ -98,11 +90,7 @@ export const MonacoEditorReactComp: React.FC<MonacoEditorProps> = (props) => {
98
90
99
91
const destroyMonaco = useCallback ( async ( ) => {
100
92
try {
101
- if ( ! wrapperRef . current . isStopping ( ) ) {
102
- await wrapperRef . current . dispose ( ) ;
103
- } else {
104
- await wrapperRef . current . getStoppingAwait ( ) ;
105
- }
93
+ await wrapperRef . current . dispose ( ) ;
106
94
} catch {
107
95
// The language client may throw an error during disposal.
108
96
// This should not prevent us from continue working.
0 commit comments