silx-kit / vscode-h5web

VSCode extension to explore and visualize HDF5 files
https://marketplace.visualstudio.com/items?itemName=h5web.vscode-h5web
MIT License
33 stars 5 forks source link

Support opening files with any extension #7

Closed axelboc closed 2 years ago

axelboc commented 2 years ago

Fix #6

I think I've finally found a way to allow opening files with any extension. I've added a new custom editor contribution point with a priority set to option. This allows showing H5Web in the "Open with..." menu of every file as suggested in #6, while still not making it the "default" editor for every file (which would break VS Code, obviously).

The downside is that H5Web now appears twice in the "Open with" menu of files with supported extensions. For this reason, I've named the fallback editor "H5Web (any extension)".

mkitti commented 2 years ago

It may be useful to take inspiration from https://github.com/microsoft/vscode-hexeditor

axelboc commented 2 years ago

@mkitti anything specific in mind? The hex editor is not associated with any specific extension, but in our case, we do want the H5Web editor to be the default editor for at least some extensions. If I've missed something, please feel free to open a PR! :pray:

mkitti commented 2 years ago

The workbench.editorAssociations they mention in the README seems like something to look into

"workbench.editorAssociations": {
    "*.hex": "hexEditor.hexedit",
    "*.ini": "hexEditor.hexedit"
},
axelboc commented 2 years ago

Nice, I can definitely add this to the README for sure, good call. I can't quite picture whether it's doable for the extension to automatically associate itself with the default extensions by updating this setting. :shrug: