diff --git a/tests/samples/codefiles/fsharp.fs b/tests/samples/codefiles/fsharp.fs new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_languages.py b/tests/test_languages.py index ceba91b..0af44c6 100644 --- a/tests/test_languages.py +++ b/tests/test_languages.py @@ -221,3 +221,19 @@ class LanguagesTestCase(utils.TestCase): language = u('Perl') self.assertEqual(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0].get('language'), language) + + def test_fsharp_detected_over_forth(self): + response = Response() + response.status_code = 500 + self.patched['wakatime.packages.requests.adapters.HTTPAdapter.send'].return_value = response + + now = u(int(time.time())) + config = 'tests/samples/configs/good_config.cfg' + entity = 'tests/samples/codefiles/fsharp.fs' + args = ['--file', entity, '--config', config, '--time', now] + + retval = execute(args) + self.assertEquals(retval, 102) + + language = u('F#') + self.assertEqual(self.patched['wakatime.offlinequeue.Queue.push'].call_args[0][0].get('language'), language) diff --git a/wakatime/packages/pygments/lexers/_mapping.py b/wakatime/packages/pygments/lexers/_mapping.py index b48ee1d..57112f4 100644 --- a/wakatime/packages/pygments/lexers/_mapping.py +++ b/wakatime/packages/pygments/lexers/_mapping.py @@ -148,7 +148,7 @@ LEXERS = { 'EvoqueLexer': ('pygments.lexers.templates', 'Evoque', ('evoque',), ('*.evoque',), ('application/x-evoque',)), 'EvoqueXmlLexer': ('pygments.lexers.templates', 'XML+Evoque', ('xml+evoque',), ('*.xml',), ('application/xml+evoque',)), 'EzhilLexer': ('pygments.lexers.ezhil', 'Ezhil', ('ezhil',), ('*.n',), ('text/x-ezhil',)), - 'FSharpLexer': ('pygments.lexers.dotnet', 'FSharp', ('fsharp',), ('*.fs', '*.fsi'), ('text/x-fsharp',)), + 'FSharpLexer': ('pygments.lexers.dotnet', 'F#', ('fsharp',), ('*.fs', '*.fsi'), ('text/x-fsharp',)), 'FactorLexer': ('pygments.lexers.factor', 'Factor', ('factor',), ('*.factor',), ('text/x-factor',)), 'FancyLexer': ('pygments.lexers.ruby', 'Fancy', ('fancy', 'fy'), ('*.fy', '*.fancypack'), ('text/x-fancysrc',)), 'FantomLexer': ('pygments.lexers.fantom', 'Fantom', ('fan',), ('*.fan',), ('application/x-fantom',)), diff --git a/wakatime/packages/pygments/lexers/dotnet.py b/wakatime/packages/pygments/lexers/dotnet.py index 4e2bc8a..a60c579 100644 --- a/wakatime/packages/pygments/lexers/dotnet.py +++ b/wakatime/packages/pygments/lexers/dotnet.py @@ -549,7 +549,7 @@ class FSharpLexer(RegexLexer): .. versionadded:: 1.5 """ - name = 'FSharp' + name = 'F#' aliases = ['fsharp'] filenames = ['*.fs', '*.fsi'] mimetypes = ['text/x-fsharp'] diff --git a/wakatime/stats.py b/wakatime/stats.py index 50392aa..f91ce01 100644 --- a/wakatime/stats.py +++ b/wakatime/stats.py @@ -311,6 +311,7 @@ def custom_pygments_guess_lexer_for_filename(_fn, _text, **options): def customize_priority(lexer): """Return an integer priority for the given lexer object.""" - if lexer.name.lower() in LANGUAGES: - lexer.priority = LANGUAGES[lexer.name.lower()] + lexer_name = lexer.name.lower().replace('sharp', '#') + if lexer_name in LANGUAGES: + lexer.priority = LANGUAGES[lexer_name] return lexer