So I have a sort of tree widget that serves as editor for a certain file type. I noticed for text editors the
Edit > Undo / Redo menu items are enable but not for mine. How do I implement it for my own widget editor? Is there a undo history service or something like that?
[original thread by Hanksha]
Ah could it but I have to register a handler for
isEnabled returns true when my widget is active?
@hanksha good idea, i would try to implement it like that as well
@anton-kosyakov How do I get the currently active/focused widget?
Ah is it via
active = a shell widget to which
current = last active shell widget
i.e. if a context menu is opened then active is undefined, but current will point to previously focused shell widget
current is useful for commands since they used from menus and quick palette
active is useful to evaluate contexts in when closures for example
Ok thanks for the details
Just found an issue regarding undo/redo:
If I have my widget editor active and focused, while there is another tab with a text editor which has changes. When I use undo/redo it applies it on the text editor and not my currently active widget editor.
your widget editor is Theia code editor?
maybe your handler does not win over code editor handler?
My widget extends
TreeWidget and serves as my editor for a certain type of file. The thing is the code editor is not even focused or visible so it should not be enabled for undo/redo commands.
I think it is done to undo if several editors were affected by some operation, even if they are not visible and focused
Could you file an issue? It seems that with at least one opened code editor, code editor will always win. Not sure yet how we can handle it.
@jankoehnlein Did you try to contribute undo/redo handlers for diagrams?
@anton-kosyakov Unfortunately not, my diagrams were all based on a text editor and re-used it’s undo/redo stack