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

Filetypes are only recognised with simple extensions #1921

Closed
Peppertop opened this issue Aug 8, 2018 · 8 comments · Fixed by #2167

Comments

@Peppertop
Copy link

commented Aug 8, 2018

I have a large number of files that are 99% JavaScript, but are processed by .Net code before they're served, so have a couple of lines of C# at the top. I've given them all filenames of the form *.js.aspx but when I try to use that in filetype_extensions.conf it has no effect and they're still considered to be XML files (per an earlier line in that file). The filetype_extensions.conf file contains this:

[Extensions]
XML=*.xml;*.sgml;*.xsl;*.xslt;*.xsd;*.xhtml;*.aspx;
Javascript=*.js;*.js.aspx;

It appears to me that Geany only recognises simple file extensions (i.e. just the bit after the last dot in the filename) rather than allowing for anything more complex. It would be great if this could be extended to support multi-part file extensions that include more than one dot.

Output from geany -V running on Ubuntu Mate 18.04.

geany 1.32 (built on 2018-01-08 with GTK 3.22.26, GLib 2.54.1)

@b4n

This comment has been minimized.

Copy link
Member

commented Aug 8, 2018

The suffixes are naively matched and the first match wins, Geany doesn't do any kind of "longest match wins". So basically you'll have to drop *.aspx from XML, or make sure it's tried after your *.js.aspx.

@Peppertop

This comment has been minimized.

Copy link
Author

commented Aug 8, 2018

I'm happy with first match wins - but that doesn't seem to be the case. I've swapped the lines so that the Javascript line is first but it doesn't appear to have made any difference.

I've reloaded the config, restarted Geany, and even checked that there's no "*.aspx" entry in /usr/share/geany/filetype_extensions.conf. Are there any other locations that I need to check that might be overriding my local setting?

(I can't just drop *.aspx from XML because although I have lots of *.js.aspx files, I have even more *.aspx files that are XML).

For clarity, my filetype_extensions.conf file now looks like this:

[Extensions]
Javascript=*.js;*.js.aspx;
XML=*.xml;*.sgml;*.xsl;*.xslt;*.xsd;*.xhtml;*.aspx;
@elextr

This comment has been minimized.

Copy link
Member

commented Aug 9, 2018

@Peppertop did you close the files, Geany remembers the filetype of open files across quit and restart so it wouldn't look at the new filetype_extensions.conf

@Peppertop

This comment has been minimized.

Copy link
Author

commented Aug 9, 2018

Yes, I closed the files, but just to be certain I've just done the following:

  1. Closed all the *.js.aspx files, quit Geany and restarted it by double-clicking one of the files (Geany is set as the default handler).

  2. Opened another file by dragging and dropping into Geany.

  3. Opened a third file by using File ‣ Open.

  4. Copied an existing file via the file manager to create a copy with a filename that Geany has never seen before, then opened it via drag and drop.

  5. Copied a file onto my local machine (they're usually opened remotely over SMB) and tried opening by dragging and dropping.

  6. Closed the file, quit Geany, double-clicked the local file.

  7. Closed the file, quit Geany, Relaunched Geany from the MATE Applications menu then loaded the local file using File ‣ Open.

In every case the file opened as XML. I think I've covered all the obvious options there, and ruled out loading from SMB as an issue, but if there's anything else I should try, please let me know.

@elextr

This comment has been minimized.

Copy link
Member

commented Aug 9, 2018

And just to be clear that was with Javascript before XML in filetype_extensions.conf

@elextr

This comment has been minimized.

Copy link
Member

commented Aug 9, 2018

Nevermind I can reproduce.

@elextr

This comment has been minimized.

Copy link
Member

commented Aug 9, 2018

It looks like the iteration order is not the order in filetype_extensions.conf, its the order in which filetypes are defined in filetypes_array so its not changable. @b4n to check this is called by this

@ntrel

This comment has been minimized.

Copy link
Member

commented May 30, 2019

its the order in which filetypes are defined in filetypes_array

Yes. With #2166 you can override just Javascript=*.js;*.js.aspx; in the user conf file and this will be preferred over a matching *.aspx system file XML pattern. This doesn't help if the latter is in the user file though.

Perhaps the longest matching pattern should win, that'd also fix #1499. I'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.