Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

GrammarRegistry.loadGrammar does not catch errors from addGrammar #23041

@winstliu

Description

@winstliu

Prerequisites

Description

While investigating winstliu/language-hclrs#4, I root-caused the issue to using a newer tree-sitter version than Atom supported. However, this was non-obvious, and the only place it was reported was in the console.

When loading grammars, loadGrammar checks to make sure that readGrammar succeeds:

this.readGrammar(grammarPath, (error, grammar) => {
if (error) return callback(error);

However, there are no checks for the subsequent addGrammar call:

this.addGrammar(grammar);
callback(null, grammar);

Even though addGrammar can fail when (eventually) calling TreeSitterLanguageMode.parse, which itself calls parser.setLanguage which can throw.

parser.setLanguage(language);

Resulting in e.g.
Incompatible tree-sitter version

Steps to Reproduce

  1. Install language-hclrs@0.0.2
  2. Set language to HCLRS

Expected behavior:

A helpful error notificaton.

Actual behavior:

Nothing! Why isn't my syntax highlighting working?

Reproduces how often:

100%

Versions

1.58.0, Windows 11 Insider.

Additional Information

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions