How do I rewrite the original logic of opening a file in Theia after clicking on it? For example, when I open a .py file, I want its content to be displayed in another widget?
@4EverM thank you for the discussion, in your custom extension you can contribute a new OpenHandler
which would handle the .py
files and open your other widget instead. Your canHandle
implementation would apply to only your expected file type (returning a high number so it is prioritized), and your open
would handle how to actually open the resource (ex: using your new widget).
Could you provide me with some example code? I’ve looked into the source code of the OpenHandler
section, and there are too many classes and interfaces involved. I’ve spent a long time on it, but all my attempts have been unsuccessful. Thank you so much!
@4EverM Take a look at the new NotebookOpenHandler
and NotebookEditorWidgetFactory
. Note that the open handler and widget factory must share the same id
.