(text: string)
| 32 | /** Write text to the editor model via pushEditOperations (preserves undo stack). |
| 33 | * No-ops silently if the editor is not mounted. */ |
| 34 | export function writeToEditorSafe(text: string) { |
| 35 | const editor = useEditorStore.getState().editor; |
| 36 | if (!editor) return; |
| 37 | const model = editor.getModel(); |
| 38 | if (!model) return; |
| 39 | model.pushEditOperations( |
| 40 | [], |
| 41 | [{ range: model.getFullModelRange(), text }], |
| 42 | () => null |
| 43 | ); |
| 44 | } |
| 45 | |
| 46 | let _isInternalWrite = false; |
| 47 |