JetBrains / MPS-extensions

MPS-extensions aims to ease language development within MPS.
https://jetbrains.github.io/MPS-extensions/
Apache License 2.0
80 stars 47 forks source link

No editorContext in query list operations #809

Closed digital-ember closed 2 months ago

digital-ember commented 3 months ago

The querylist operations for deleting and adding new elements currently do not provide editorContext. Especially for the use case of setting a selection after deleting or adding an element, this would be very useful.

alexanderpann commented 2 months ago

I've added this parameter in https://github.com/JetBrains/MPS-extensions/pull/832 but it won't help setting the selection. I couldn't figure out how to make it work. The fact that the nodes don't belong to the same root node probably plays a big role in why the normal way with something likeeditorContext.flushEvents(); editorContext.select(node) doesn't work.

digital-ember commented 1 month ago

A more general question related to that (even though I understand it does not solve the selection issue here in querylist): My go-to solution to similar issues used to be to call editorContext.getEditorComponent().rebuildEditorContent(); before trying to set the selection, but I see that editorContext.flushEvent() also seems to work in cases where I needed to call editorContext.getEditorComponent().rebuildEditorContent() before. Is it better to call flushEvents() over rebuildign the editor to ensure selection is working?

alexanderpann commented 1 month ago

flushEvents() should be enough to process all the changes happening to the model. rebuildEditorContent() invalidates the editor and layouts it again which is unnecessary.