MCPcopy Index your code
hub / github.com/DTStack/molecule / initEditorEvents

Method initEditorEvents

src/controller/editor.tsx:244–291  ·  view source on GitHub ↗
(
        editorInstance: MonacoEditor.IStandaloneCodeEditor,
        groupId: UniqueId
    )

Source from the content-addressed store, hash-verified

242 };
243
244 public initEditorEvents(
245 editorInstance: MonacoEditor.IStandaloneCodeEditor,
246 groupId: UniqueId
247 ) {
248 if (!editorInstance) return;
249
250 editorInstance.onDidChangeModelContent((event: any) => {
251 const { current } = this.editorService.getState();
252 const tab = current?.tab;
253 if (!tab) return;
254
255 const currentEditorUri = current.editorInstance?.getModel()?.uri;
256 const updateEditorUri = editorInstance?.getModel()?.uri;
257 if (currentEditorUri?.path !== updateEditorUri?.path) return;
258
259 const newValue = editorInstance.getModel()?.getValue();
260 const updatedTab = {
261 ...tab,
262 data: { ...tab.data, value: newValue },
263 };
264
265 this.editorService.updateTab(updatedTab, groupId);
266 this.updateStatusBar(editorInstance);
267
268 this.emit(EditorEvent.OnUpdateTab, updatedTab);
269 });
270
271 editorInstance.onDidFocusEditorText(() => {
272 const group = this.editorService.getGroupById(groupId);
273 if (group?.tab!.id) {
274 this.editorService.setActive(groupId, group.tab.id);
275 this.updateEditorLineColumnInfo(editorInstance);
276 }
277 });
278
279 editorInstance.onDidChangeCursorSelection(() => {
280 this.updateEditorLineColumnInfo(editorInstance);
281 });
282
283 editorInstance.onDidBlurEditorText(() => {
284 const { current } = this.editorService.getState();
285 const tab = current?.tab;
286 if (tab?.id) {
287 const viewState = editorInstance?.saveViewState();
288 this.editorStates.set(tab.id?.toString(), viewState);
289 }
290 });
291 }
292
293 public getViewState = (id: UniqueId) => {
294 return this.editorStates.get(id);

Callers 2

EditorControllerClass · 0.95
editor.test.tsFile · 0.80

Calls 7

updateStatusBarMethod · 0.95
getStateMethod · 0.80
emitMethod · 0.80
updateTabMethod · 0.65
getGroupByIdMethod · 0.65
setActiveMethod · 0.65

Tested by

no test coverage detected