Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-reload filetypes when filetypes.toml is saved #1177

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Akuli
Copy link
Owner

@Akuli Akuli commented Aug 25, 2022

Fixes #411

def after_save(tab: tabs.FileTab, junk: object) -> None:
if tab.path == Path(dirs.user_config_dir) / "filetypes.toml":
# Reload all filetypes when the user saves filetypes.toml.
# If user has chosen a custom filetype, leave the tab alone.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just find a filetype with whatever filetype_name is currently used? It still needs a fallback to get_filetype_for_tab() in case the user deletes a filetype.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user hasn't selected a custom filetype, we should call get_filetype_for_tab(), because it is possible that filename_patterns was modified.

@Akuli
Copy link
Owner Author

Akuli commented Aug 27, 2022

When ran locally, the new test succeeds on both Windows and Linux (don't have a mac). In CI it succeeds on linux but fails on windows and mac. I will probably just skip the failures, as it doesn't seem to have anything to do with whether it actually works

@Akuli
Copy link
Owner Author

Akuli commented Aug 27, 2022

Still passes locally.

@Akuli
Copy link
Owner Author

Akuli commented Aug 27, 2022

This will interact badly with the editorconfig plugin. It should be able to override anything that filetypes sets.

@Akuli Akuli marked this pull request as draft August 27, 2022 23:48
@Moosems
Copy link
Contributor

Moosems commented May 16, 2023

You could try using watchdog for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

filetypes.toml refresh on save
2 participants