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

Feat: Auto Extension Fix #1653

Open
Kesuaheli opened this issue Nov 25, 2024 · 1 comment
Open

Feat: Auto Extension Fix #1653

Kesuaheli opened this issue Nov 25, 2024 · 1 comment
Labels
✨ feature New feature or request /java-edition
Milestone

Comments

@Kesuaheli
Copy link

It frequently happens that one misspelled a file extension e.g. .mcfuntion instead of .mcfunction.
Misode hat the Idea if Spyglass could detect that. Which gave me the following concept:


I'm thinking of a popup notification in the bottom right. Which says something like, "The file you just created has an unknown extension for the function folder. Expected '.mcfunction'."
And then there are two buttons. One that just closes it. And one to automagically rename it. (Ik, the close button is redundant, as you can close a popup on the :95_x:. But I feel like it's better UX to have it next to the button that does stuff)

That same concept can be applied to all folders. For example:

  • function (functions) expects .mcfunction
  • tags/block (tags/blocks) expects .json
  • ...
    Same for resource pack:
  • blockstates expects .json
  • I don't exactly know the shader stuff, but I do know there's some special extensions...
  • textures expects .png
  • ...

A sort of config option would be cool; obviously. Maybe even overrides.
Simply turning that on/off.
By overrides, I mean a whitelist-ish thing, where you specify file extensions that Spyglass won't complain about. Example:

{
  "function": [
    ".foo"
  ],
  "tags/function": [
    ".bar",
    "barfoo"
  ]
}

Would result in a behaviour like:

  • When the user creates a file in data/*/function/ named not_a_function.foo, Spyglass doesn't show the renaming popup.
  • When the user creates a file in data/*/tags/function named hello_world_barfoo, Spyglass doesn't show the renaming popup. (because the created file ends in one of the given strings "barfoo".)

If the created file does not exist in the whitelist and the user decides to let Spyglass rename it, Spyglass cuts everything from (including) the last dot ., if any. And then the expected extension is added at the end. Example:

  • Renaming data/*/function/tick.mcfun:
    1. Cut: tick.mcfun
    2. Add: tick.mcfunction
  • Renaming data/*/tags/item/potato
    1. Cut: potato (unchanged, as there's no .)
    2. Add: potato.json
  • ...

Maybe also an option to set the expected extensions? Like this:

{
  "function": {
    "replace": ".mcfunction",
    "allow": [
      ".foo"
    ]
  },
  "tag/biome": {
    "replace": "_custom.json",
    "allow": [
      "foobar"
    ]
  }
}
@SPGoding
Copy link
Member

Thanks for the write up. Popups are rather un-LSP-ly, but I think a warning on the first line of the file with a quick fix for renaming it would work? We could even add another quick fix for automatically changing the config file to allow the current file name/extension, but that might be too much magic.

@misode misode added ✨ feature New feature or request /java-edition labels Nov 27, 2024
@misode misode added this to the Backlog milestone Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feature New feature or request /java-edition
Projects
None yet
Development

No branches or pull requests

3 participants