Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

File Extension Detection (Filenames with dots) #8042

Open
Hirse opened this issue Jun 5, 2014 · 10 comments
Open

File Extension Detection (Filenames with dots) #8042

Hirse opened this issue Jun 5, 2014 · 10 comments
Assignees

Comments

@Hirse
Copy link

Hirse commented Jun 5, 2014

I am using the Brackets Icons Extension to get a better overview of my file types and I was surprised that some .js files were not marked as the other JavaScript files.
file-extension_icons

After reloading Brackets without extensions, I saw that the file extension detection is not what I expected it to be.
file-extension
I am not sure, if this is the way it should be, but for me the extension would be the part of the file after the last . in the filename.
It also doesn't look like Brackets has general problems with dots in filenames as script.abc.js is handled correctly.
Only known file extension at the end of the filename seem to be added to the extension:
file-extension_long

@peterflynn
Copy link
Member

Looks like a bug in the recently added FileUtils.getSmartFileExtension(). Assigning to @zaggino as I believe he wrote that code...

@peterflynn
Copy link
Member

Hmm, actually -- looks like this behavior was specifically requested by @redmunds when reviewing the PR #7242. Setting to 'needs review' so we can resolve that question...

(Personally I think we should only resolve LanguageManager-recognized extensions, and not try to get fancier -- although the examples in the screenshots above might be a little contrived, it does seem odd & potentially confusing that we act as if we're recognizing a longer extension in the file tree UI while the actual editor mode is only respecting a subset of that file extension).

@Hirse
Copy link
Author

Hirse commented Jun 5, 2014

I made up the filenames in the screenshots above of course. In the last one primarily to show that you can chain as many extension as you like apparently.

This is a screenshot of files in my actual project using the OpenUI5 Framework. To the left with activated extensions Brackets Icons and Brackets Extension Highlighter and without any extension to the right.
file-extension_openui5

@redmunds
Copy link
Contributor

redmunds commented Jun 5, 2014

@peterflynn Note that the coloring was changed to match the renaming pattern that had already been established, so that also needs to be considered with any changes. People are generally more concerned with the unique part of the filename than the file extension.

This is done so every combination of all LanguageManager-recognized file extensions (e.g. .php.js, .php.css) do not need to be exhaustively be defined in language.json to reflect all of the combined file extensions being used in the wild. Cases like .js.erb do need to explicitly be defined because they do not follow the standard naming convention.

@redmunds redmunds assigned redmunds and unassigned zaggino Jun 5, 2014
@redmunds
Copy link
Contributor

redmunds commented Jun 5, 2014

Re-assigning to me because this is behaving as designed.

@dangoor
Copy link
Contributor

dangoor commented Jun 9, 2014

Is .php.js a real file extension? Do people actually configure their servers for that? Here's a suggestion to use styles.php when wanting to PHP preprocess CSS. People say more or less the same thing about JS on StackOverflow.

Somewhat recently, I saw a system that would automatically process files based on their extensions. A .html.md file would automatically get converted from Markdown to HTML. We wouldn't want to infer that the file was an HTML file, though, because it's actually Markdown file.

I agree with what @peterflynn says above that it seems like we're best off just using extensions explicitly defined in LanguageManager (or the contents after the last . if it's not in LanguageManager). Users can now also define additional extension mappings in their prefs if they wish.

@peterflynn
Copy link
Member

I think the inconsistencies in the screenshot above with a real-world project are another good example of why the current behavior is confusing. (In addition to the concerns I raised above about different parts of Brackets treating the same file as having differing file extension parts).

@dangoor
Copy link
Contributor

dangoor commented Jun 16, 2014

Reviewed medium priority to @redmunds to change the behavior to:

  1. use what's defined in LanguageManager
  2. if not expressly in LanguageManager, use what follows the final .

@redmunds
Copy link
Contributor

@dangoor

Is .php.js a real file extension? Do people actually configure their servers for that?

Yes. Yes. I'm not sure how common it is, but people do it.

The file name/extension coloring changes were done to be consistent with what gets selected during file renaming (issues #7265). So you want file renaming behavior changed, too, right?

@dangoor
Copy link
Contributor

dangoor commented Aug 19, 2014

I'm looking at the file renaming behavior right now as part of #8788. I do think the renaming behavior and coloring of extensions should be consistent.

I might take this on, but this issue seems separable enough from the rest of the project manager revamp that it is not clear whether I should. I'm going to make a note in #8788 about it, though.

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

No branches or pull requests

5 participants