(hub: Hub, state: MonacoPaneState & EditorState, container: Container)
| 117 | private revealJumpStackHasElementsCtxKey: editor.IContextKey<boolean>; |
| 118 | |
| 119 | constructor(hub: Hub, state: MonacoPaneState & EditorState, container: Container) { |
| 120 | super(hub, container, state); |
| 121 | |
| 122 | this.alertSystem = new Alert(); |
| 123 | this.alertSystem.prefixMessage = 'Editor #' + this.id; |
| 124 | |
| 125 | const languages = languagesService.getLanguagesOrFail(); |
| 126 | if ((state.lang as any) === undefined && Object.keys(languages).length > 0) { |
| 127 | if (!this.currentLanguage) { |
| 128 | // Primarily a diagnostic for urls created outside CE. Addresses #4817. |
| 129 | this.alertSystem.notify('No language specified for editor', {}); |
| 130 | } else { |
| 131 | this.alertSystem.notify('No language specified for editor, using ' + this.currentLanguage.id, {}); |
| 132 | } |
| 133 | } else if (!(state.lang in languages) && Object.keys(languages).length > 0) { |
| 134 | this.alertSystem.alert('State Error', 'Unknown language specified for editor', {isError: true}); |
| 135 | } |
| 136 | |
| 137 | if (this.currentLanguage) this.onLanguageChange(this.currentLanguage.id, true); |
| 138 | |
| 139 | if (state.source !== undefined) { |
| 140 | this.setSource(state.source); |
| 141 | } else { |
| 142 | this.updateEditorCode(); |
| 143 | } |
| 144 | |
| 145 | const startFolded = /^[/*#;]+\s*setup.*/; |
| 146 | if (state.source?.match(startFolded)) { |
| 147 | // With reference to https://github.com/Microsoft/monaco-editor/issues/115 |
| 148 | // I tried that and it didn't work, but a delay of 500 seems to "be enough". |
| 149 | // FIXME: Currently not working - No folding is performed |
| 150 | setTimeout(() => { |
| 151 | this.editor.setSelection(new monaco.Selection(1, 1, 1, 1)); |
| 152 | this.editor.focus(); |
| 153 | unwrap(this.editor.getAction('editor.fold')).run(); |
| 154 | //this.editor.clearSelection(); |
| 155 | }, 500); |
| 156 | } |
| 157 | |
| 158 | if (this.settings.useVim) { |
| 159 | this.enableVim(); |
| 160 | } |
| 161 | |
| 162 | // We suppress posting changes until the user has stopped typing by: |
| 163 | // * Using _.debounce() to run emitChange on any key event or change |
| 164 | // only after a delay. |
| 165 | // * Only actually triggering a change if the document text has changed from |
| 166 | // the previous emitted. |
| 167 | this.lastChangeEmitted = null; |
| 168 | this.onSettingsChange(this.settings); |
| 169 | // this.editor.on("keydown", () => { |
| 170 | // // Not strictly a change; but this suppresses changes until some time |
| 171 | // // after the last key down (be it an actual change or a just a cursor |
| 172 | // // movement etc). |
| 173 | // this.debouncedEmitChange(); |
| 174 | // }); |
| 175 | } |
| 176 |
nothing calls this directly
no test coverage detected