@@ -6,7 +6,7 @@ import { languages, workspace, TextDocument as VsCodeTextDocument } from 'vscode
66import { getLanguageService , TextDocument } from 'vscode-json-languageservice' ;
77import { createConverter as createCodeConverter } from 'vscode-languageclient/lib/common/codeConverter.js' ;
88import { createConverter as createProtocolConverter } from 'vscode-languageclient/lib/common/protocolConverter.js' ;
9- import { createDefaultJsonContent , createJsonEditor } from '../common.js' ;
9+ import { createDefaultJsonContent , createJsonEditor , performInit } from '../common.js' ;
1010
1111import { buildWorkerDefinition } from 'monaco-editor-workers' ;
1212buildWorkerDefinition ( '../../../node_modules/monaco-editor-workers/dist/workers/' , new URL ( '' , window . location . href ) . href , false ) ;
@@ -17,10 +17,16 @@ const protocolConverter = createProtocolConverter(undefined, true, true);
1717const createEditor = async ( ) => {
1818 let mainVscodeDocument : VsCodeTextDocument | undefined ;
1919 const languageId = 'json' ;
20+
21+ await performInit ( true ) ;
22+
23+ workspace . onDidOpenTextDocument ( ( _event ) => {
24+ mainVscodeDocument = workspace . textDocuments [ 0 ] ;
25+ } ) ;
26+
2027 const jsonEditor = await createJsonEditor ( {
2128 htmlElement : document . getElementById ( 'container' ) ! ,
22- content : createDefaultJsonContent ( ) ,
23- init : true
29+ content : createDefaultJsonContent ( )
2430 } ) ;
2531
2632 const createDocument = ( vscodeDocument : VsCodeTextDocument ) => {
@@ -83,6 +89,7 @@ const createEditor = async () => {
8389 } ) ;
8490
8591 const validate = ( ) => {
92+ console . log ( 'validate' ) ;
8693 const document = createDocument ( mainVscodeDocument ! ) ;
8794 cleanPendingValidation ( document ) ;
8895 pendingValidationRequests . set ( document . uri , window . setTimeout ( ( ) => {
@@ -120,11 +127,6 @@ const createEditor = async () => {
120127 jsonEditor . modelRef . object . textEditorModel ! . onDidChangeContent ( ( ) => {
121128 validate ( ) ;
122129 } ) ;
123-
124- workspace . onDidChangeTextDocument ( ( _event ) => {
125- mainVscodeDocument = workspace . textDocuments [ 0 ] ;
126- validate ( ) ;
127- } ) ;
128130} ;
129131
130132createEditor ( ) ;
0 commit comments