()
| 186 | const container = containerRef.current; |
| 187 | |
| 188 | const initEditor = async () => { |
| 189 | try { |
| 190 | await monacoInitManager.initialize(); |
| 191 | |
| 192 | if (isUnmountedRef.current) return; |
| 193 | |
| 194 | themeManager.initialize(); |
| 195 | |
| 196 | const originalModel = monaco.editor.createModel( |
| 197 | originalContentRef.current, |
| 198 | languageRef.current, |
| 199 | generateUri('original') |
| 200 | ); |
| 201 | const modifiedModel = monaco.editor.createModel( |
| 202 | modifiedContentRef.current, |
| 203 | languageRef.current, |
| 204 | generateUri('modified') |
| 205 | ); |
| 206 | originalModelRef.current = originalModel; |
| 207 | modifiedModelRef.current = modifiedModel; |
| 208 | |
| 209 | const overrides: EditorOptionsOverrides = { |
| 210 | readOnly: readOnlyRef.current, |
| 211 | minimap: showMinimapRef.current, |
| 212 | theme: themeRef.current, |
| 213 | }; |
| 214 | |
| 215 | const diffOptions = buildDiffEditorOptions({ |
| 216 | config: configRef.current, |
| 217 | preset: presetRef.current, |
| 218 | overrides, |
| 219 | }); |
| 220 | |
| 221 | const diffEditor = monaco.editor.createDiffEditor(container, { |
| 222 | ...diffOptions, |
| 223 | renderSideBySide: renderSideBySideRef.current, |
| 224 | renderOverviewRuler: renderOverviewRulerRef.current, |
| 225 | renderIndicators: renderIndicatorsRef.current, |
| 226 | originalEditable: originalEditableRef.current, |
| 227 | ignoreTrimWhitespace: ignoreTrimWhitespaceRef.current, |
| 228 | }); |
| 229 | diffEditorRef.current = diffEditor; |
| 230 | |
| 231 | diffEditor.setModel({ |
| 232 | original: originalModel, |
| 233 | modified: modifiedModel, |
| 234 | }); |
| 235 | |
| 236 | registerEventListeners(diffEditor, modifiedModel); |
| 237 | |
| 238 | setIsReady(true); |
| 239 | |
| 240 | onEditorReadyRef.current?.(diffEditor, originalModel, modifiedModel); |
| 241 | |
| 242 | } catch (error) { |
| 243 | log.error('Failed to initialize diff editor', error); |
| 244 | } |
| 245 | }; |
no test coverage detected