JustusAdam/language-haskell

can't activate at stratup

Closed this issue · 5 comments

OS Windows10(1803)
VSCODE 1.33.0

I update vscode to 1.33.0 today, and cant't activate this plugin at start up.
developper tools console shows below message.

Activating extension 'justusadam.language-haskell' failed: Cannot read property 'source' of null.

It occurs same error in vscode-insiders(1.34.0).

Please any fix?

pzzp commented

I have same issue.
OS Archlinux.
vscode 1.33.0

I believe the problem is here:

export function activate(context: vscode.ExtensionContext) {

    vscode.languages.setLanguageConfiguration('haskell', {
        indentationRules: {
            // ^.*\{[^}"']*$
            increaseIndentPattern: vscode.workspace.getConfiguration('haskell').indentationRules.enabled
                ? /(\bif\b(?!')(.(?!then))*|\b(then|else|m?do|of|let|in|where)\b(?!')|=|->|>>=|>=>|=<<|(^(data)( |\t)+(\w|')+( |\t)*))( |\t)*$/
                : null,
            decreaseIndentPattern: null
        },
        wordPattern: /([\w'_][\w'_\d]*)|([0-9]+\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)/
    })  	
}

See how we set decreaseIndentPattern to null (and sometimes increaseIndentPattern). These parameters are defined as non-optional in VSCode API:
https://code.visualstudio.com/api/references/vscode-api#IndentationRule
We wouldn't be able to set it to null if we were using TypeScript.

I quickly tested using "" instead of null and it worked, but I am not sure if an empty string is a correct RegEx here and what it matches....

I amended #85 to fix this. Turns out while you can't pass null, you can pass it a new RegExp(null) which has the same behaviour 😉

Thanks!

@JustusAdam, @AlexeyRaga, very thank you.
Haskell Syntax Highlighting 2.6.0 All works for vscode and vscode-insider.