Skip to content

Commit

Permalink
fix: Fix the error the variable CPDisposable does not exist. (#162 #…
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Aug 16, 2022
1 parent 3348fdb commit 7e0fd05
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ function MonacoEditor(props: MonacoEditorProps, ref: ((instance: RefEditorInstan
}, [options.theme])

useEffect(() => {
let CPDisposable: monaco.IDisposable;

This comment has been minimized.

Copy link
@PisecesPeng

PisecesPeng Aug 16, 2022

Contributor

Ah! its my, 😁 thanks and LGTM!

if (editor.current && autoComplete) {
if (editor?.current?.getModel() && editor?.current?.getPosition()) {
const CPDisposable: monaco.IDisposable
= monaco.languages.registerCompletionItemProvider(language, {
CPDisposable = monaco.languages.registerCompletionItemProvider(language, {
provideCompletionItems: (model, position) => {
return {
suggestions: autoComplete(model, position)
Expand All @@ -130,7 +130,7 @@ function MonacoEditor(props: MonacoEditorProps, ref: ((instance: RefEditorInstan
}
}
return () => {
CPDisposable.dispose();
CPDisposable && CPDisposable.dispose();
}
}, [language, autoComplete]);

Expand Down

0 comments on commit 7e0fd05

Please sign in to comment.