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

"Save As" does not update filetype #2124

Open
tivrfoa opened this issue Apr 14, 2019 · 2 comments
Open

"Save As" does not update filetype #2124

tivrfoa opened this issue Apr 14, 2019 · 2 comments

Comments

@tivrfoa
Copy link

tivrfoa commented Apr 14, 2019

I am using 1.32 (Ubuntu)
To reproduce:

  1. Save a html file
  2. Save As js file

bug: The filetype continues html
maybe something like this works:

diff --git a/src/dialogs.c b/src/dialogs.c
index 7c083512..65721246 100644
--- a/src/dialogs.c
+++ b/src/dialogs.c
@@ -490,6 +490,7 @@ static gboolean handle_save_as(const gchar *utf8_filename, gboolean rename_file)
 {
        GeanyDocument *doc = document_get_current();
        gboolean success = FALSE;
**+       GeanyFiletype *ft = filetypes_detect_from_document(doc);**
 
        g_return_val_if_fail(doc != NULL, FALSE);
        g_return_val_if_fail(!EMPTY(utf8_filename), FALSE);
@@ -511,6 +512,8 @@ static gboolean handle_save_as(const gchar *utf8_filename, gboolean rename_file)
        success = document_save_file_as(doc, utf8_filename);
 
        build_menu_update(doc);
**+       document_set_filetype(doc, ft);**
+
        return success;
 }
@elextr
Copy link
Member

elextr commented Apr 14, 2019

It is intended that saving a file under a different name does not change the filetype. Filetypes are only automatically detected when a file is first opened, and after that it is not changed by Geany since a user can set it from the Document menu.

Example use-cases are scripts embedded in HTML and the user selects the filetype to be the script language so its highlighted and parsed, even though the filename is still .html, or cases where Geany detects the filetype wrongly and the user sets it. It would be annoying if the filetype kept changing.

It might be possible to have an option in the Save As dialog, but clicking that is not much of a saving from Document->Set Filetype->select type before or after saving.

@tivrfoa
Copy link
Author

tivrfoa commented Apr 14, 2019

Hi elextr.
So, my case I had an index.html file and "Save as" main.js.
Then there was no syntax highlight, and I realized the filetype for Geany was the old one.
Then I had to reopen the file (Document->Set Filetype->select type is also an option)

So it is much better if this could happen automatically, and it is probably a simple change.

Thank you.

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

No branches or pull requests

2 participants