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

File named "build" always opens as "NAnt Build FIle" type #1862

Closed
madneon opened this issue Feb 2, 2019 · 4 comments · Fixed by #3569
Closed

File named "build" always opens as "NAnt Build FIle" type #1862

madneon opened this issue Feb 2, 2019 · 4 comments · Fixed by #3569

Comments

@madneon
Copy link

madneon commented Feb 2, 2019

How to reproduce:
Create file named "build", put anything into it, eg. #!/bin/bash, and then save it.
Closing and opening the file switches to "NAnt Build File", also on Sidebar file is wrongly detected.

@deathaxe
Copy link
Collaborator

deathaxe commented Feb 3, 2019

  1. The NAnt Build File is defined in C#/Build.sublime-syntax.
  2. This syntax is associated with the build file extension.
  3. ST uses file extensions to choose the syntax first. If none matches, the first_line_match rule is used. That's why the shebang is ignored.
  4. ST uses the last part of a file path as "extension", which means it matches both foo.build and build. We could argue about a file named build is to be a file extension, but changing the behavior would break syntax assignment for files like .gitignore.

With that said this issue is not related with the Default Packages and can not be fixed in the syntax defintions without changing ST core behavior.

A backward compatible solution would probably be to introduce a new file_pattern context which was used instead of file_extensions if exists. It would then need to support simple file patterns.

file_patterns:
  - *.build     // file extension
  - build       // file name

@keith-hall
Copy link
Collaborator

see sublimehq/sublime_text#1353 for a prior discussion

@michaelblyons
Copy link
Collaborator

michaelblyons commented Feb 3, 2019

FWIW, I use ApplySyntax for more fine-grained control until things like @deathaxe's wish are implemented. Here's the main problem I use it for:

  • ~/.ssh/config
  • ~/projects/foo/.git/config

Both files have the same filename. Neither one has a shebang or other guaranteed first line stuff. How do you distinguish them? Even with @deathaxe's system, can the patterns test the full path?

Even ApplySyntax comes with a caveat: I have to disable its default rules by setting default_syntaxes: [] to avoid interfering with the PackageDev-defined languages for special XML files (.tmPreferences, etc.). Case-sensitivity problem fixed by facelessuser/ApplySyntax#128.

@FichteFoll
Copy link
Collaborator

As a side note, I'm not sure build is a specific enough extension to justify having it opened with the C++ build system thingy by default. Meson, for example, also uses the .build extension, though that is always written as meson.build.
Can you think of other examples?

deathaxe added a commit to deathaxe/sublime-packages that referenced this issue Nov 18, 2022
Fixes sublimehq#1862

This commit unassignes `build` file extension from NAnt Build File
syntax as it is a too generic extension used by many syntaxes.

With this change `*.build` files need to be assigned to NAnt Build File
manually if desired.
deathaxe added a commit that referenced this issue Nov 18, 2022
Fixes #1862

This commit unassignes `build` file extension from NAnt Build File
syntax as it is a too generic extension used by many syntaxes.

With this change `*.build` files need to be assigned to NAnt Build File
manually if desired.
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 a pull request may close this issue.

5 participants