Search code examples
visual-studio-codehovervscode-extensionsmousehover

why hover doesn't work on Linux using VSCode after the latest release of VSCode(1.59.1)?


I am actually trying to make a VSCode extension that will provide hover functionality. I had managed to make it work but since the last release of VSCode (1.59.1) it doesn't work anymore on Linux computers (have tested on Ubuntu and CentOs), but still works on Windows and MacOS. Here is my client js file (./client/extension.js):

const vscode = require('vscode');


function activate(context) {

    console.log('Congratulations, your extension of YALES2 is now active!');
    console.warn('Congratulations, your extension of YALES2 is now active!')
    let disposable = vscode.commands.registerCommand('extension.mamar', () => {
        vscode.window.showInformationMessage("Hover");
    });
    
    context.subscriptions.push(disposable);

    disposable = vscode.languages.registerHoverProvider('yales2test', {
        provideHover(document, position, token) {

            const range = document.getWordRangeAtPosition(position);
            const word = document.getText(range);
            if (word=="ABSORBING_BOUNDARIES") {
                return new vscode.Hover({ language: "yales2test", value: 'Message to show on Hover'});
            }
        }
    });

    context.subscriptions.push(disposable)
}

function deactivate() { }

module.exports = {
    activate,
    deactivate
}

And on my package.json I have:

"activationEvents": [
        "onCommand:extension.mamar",
        "onLanguage:yales2test"
     ],
     "main": "./client/extension.js",
     "contributes": {
        "capabilities": {
            "hoverProvider": "true"
        }

I also tried to downgrade VSCode to 1.58.2 and there the hover works! Would anyone know why it doesn't work anymore on Linux when using VSCode 1.59.1, please?


Solution

  • The problem was the length of my extension.js since it had a huge number of if ... else if... resulting to an exceed of memory! So always think to optimize your code!