Skip to content

Auto detection for custom languages #9

@alex-oser

Description

@alex-oser

I have an extension which provides some language support (folding and highlighting) for file trees. When opening an untitled file and pasting in a tree, the extension will try to set the language to tree if it has some specific characters (ex. ├──, └──). However, once language detection kicks in it automatically changes it to ini.

I was testing the language detection code and can clearly see that for a tree file it somehow detects ini with 100% confidence. So there are 2 questions:

  1. Is it a bug that this is being detected as an ini file?
  2. Is there any process for hooking into/add languages to the custom detection API?

I tested the language detection code with the below

const vsl = require("@vscode/vscode-languagedetection");
const modulOperations = new vsl.ModelOperations();
(async () => {
    const result = await modulOperations.runModel(`
    ├── functions
    ├── src
    │    ├── articles
    │    ├── components
    │    ├── constants
    │    ├── contexts
    │    ├── data
    │    ├── hooks
    │    ├── i18n
    │    │    └── locales
    │    ├── modals
    │    │    └── sections
    │    ├── pages
    │    │    ├── app
    │    │    └── r
    │    ├── styles
    │    ├── templates
    │    └── utils
    └── static
        └── images
            ├── screenshots
            └── templates
    `);
    console.log(result);
})();

Output:

image

Metadata

Metadata

Labels

feature-requestRequest for new features or functionality

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions