daviduuang / ini-for-vscode

Provide outline view and section folding for INI file.
GNU General Public License v3.0
18 stars 7 forks source link

Activate the plugin on any ini file #1

Open Wosi opened 6 years ago

Wosi commented 6 years ago

The plugin only works properly for ´.ini´, ´.cfg´ and ´.reg´ files. With these changes it will work for any file being opened with language mode = 'ini' (regardless its file extension).

rbolsius commented 2 years ago

This fix in this pull request would be very welcomed. I have INI files on platforms with case-sensitive file systems that do not work with this extension because the file extension is uppercase (.INI) or even some other file extension that is not one of the default extensions.

Also, the fix could be simplified even further by just checking if the language is 'ini'. There is no need for the second line that also checks if the language is 'ini' and the scheme is 'untitled'. The following is sufficient to activate the extension for any INI document whether it is opened from a file or is an untitled/unsaved document:

function activate(context) {
    context.subscriptions.push(vscode.languages.registerDocumentSymbolProvider([
        { language: 'ini' },
    ], new documentSymbolProvider_1.IniDocumentSymbolProvider()));

    context.subscriptions.push(vscode.languages.registerFoldingRangeProvider([
        { language: 'ini' },
    ], new foldingRangeProvider_1.IniFoldingRangeProvider()));
}