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

Brackets reset default language to plain/text #12970

Closed
2 of 3 tasks
Athorcis opened this issue Dec 5, 2016 · 2 comments · Fixed by #12979
Closed
2 of 3 tasks

Brackets reset default language to plain/text #12970

Athorcis opened this issue Dec 5, 2016 · 2 comments · Fixed by #12979

Comments

@Athorcis
Copy link

Athorcis commented Dec 5, 2016

Prerequisites

  • Can you reproduce the problem with Debug -> Reload Without Extensions?
    Only because this bug is linked to highlighting extensions.
  • Did you perform a cursory search to see if your bug or enhancement is already reported?
  • Did you read the Troubleshooting guide?

Description

Brackets reset language for a file type to text if the language set as default for the file type is defined by an extension and this extension doesn't define this file type in the list provided to language manager

Steps to Reproduce

  1. Download an extension which highlight a language not supported by Brackets (this one by example)
  2. Open a file which file type is not supported by the extension you installed
  3. Set the language to the one supported by the extension
  4. Set this language as the default one
  5. Reload Brackets (with extensions).

Expected behavior: The language for the file is the one supported by the extension

Actual behavior: The language is Text.

Versions

Windows 10 / Brackets 1.8
Also reproduced under Windows 7 / Brackets 1.8 (with only one extension the one mentioned above)

@haslam22
Copy link
Contributor

haslam22 commented Dec 6, 2016

Seems to be caused by _updateFromPrefs in LanguageManager.js. Languages defined by brackets extensions (like twig) aren't loaded straight away, so it will fail to find them when trying to load the preferences file for the first time. Further calls to _updateFromPrefs only look at changes to the preferences file so it won't pick up on the new languages. Adding a loop to check for invalid mappings fixes this issue:

        newNames.forEach(function(name) {
            var language  = _fileExtensionToLanguageMap[name];
            // Mapping returns undefined, but language exists
            if(!language && getLanguage(newMapping[name])) {
                // Add the extension to the language
                language = getLanguage(newMapping[name]);
                language[state.add](name);
            }
        });

edit: it's actually a bit more complicated than this, and requires a few changes, but I'll try to work on a fix

zaggino added a commit that referenced this issue Dec 20, 2016
Fix for #12970: Non-default languages and user preferences bug
@zaggino
Copy link
Contributor

zaggino commented Dec 20, 2016

Fixed by #12979 to be released in 1.9

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

Successfully merging a pull request may close this issue.

3 participants