Configuration System

    There are two types of configuration types.

    1. editor configuration (editor)
    2. project configuration (project)

    The editor configuration is used to store some editor-related user settings and data, and is divided into three priority levels, from high to low, as follows.

    If there is no corresponding configuration in , the configuration in global will be used, and if no corresponding configuration in global is found, the default default configuration will be used.

    Project Configuration

    The project configuration is used to store some project-related user settings and data, and is divided into two priority levels, from highest to lowest.

    1. local -> default

    To use the configuration system, you need to define the profile information in the contributions field of the extension definition file package.json, as follows.

    1. {
    2. "contributions": {
    3. "profile": {
    4. "editor": {
    5. "test.a": {
    6. "default": 0,
    7. "message": "editorTestAChanged",
    8. "label": "Test Editor configuration"
    9. }
    10. },
    11. "test.a": {
    12. "default": 1,
    13. "message": "projectTestAChanged",
    14. "label": "Test Project Configuration"
    15. }
    16. }
    17. },
    18. }

    contributions.profile The related fields are interpreted as follows.

    • editor:{} - editor configuration
    • project:{} - project configuration
    • test.a:{} - key for the configuration of test.a
    • default:any - the default value of this configuration item, optional parameter
    • message:string - the message that will be triggered when this configuration item is modified, optional
    • label:string - where the configuration can be displayed, this description may be displayed. Supports i18n:key format, optional parameters

    The TypeScript interface associated with profile is defined as follows.

    1. import packageJSON from '../package.json';

    If the last parameter of Editor.Profile.getConfig is empty, a priority match will be performed.

    1. await Editor.Profile.getConfig(packageJSON.name, 'test.a'); // 0
    2. await Editor.Profile.getConfig(packageJSON.name, 'test.a', 'local'); // undefined
    3. await Editor.Profile.getConfig(packageJSON.name, 'test.a', 'global'); // undefined

    Modify the Editor Configuration

    Call getConfig after modifying the configuration with the following code to see the corresponding changes.

    If the last parameter of Editor.Profile.getProject is empty, a match will be performed.

    If the fetch location (either local, default) is specified, the corresponding value will be returned. As shown below, the local is undefined because it is not set.

    1. await Editor.Profile.getProject(packageJSON.name, 'test.a'); // 1
    2. await Editor.Profile.getProject(packageJSON.name, 'test.a', 'local'); // undefined

    Modify the Project Configuration

    Call getProject after modifying the configuration with the following code to see the corresponding changes.

    1. await Editor.Profile.setProject(packageJSON.name, 'test.a', 1);
    2. await Editor.Profile.setProject(packageJSON.name, 'test.a', 'local', 2);

    Project Configuration Storage Path

    HierarchyPath
    local{projectPath}/settings/v2/extensions/{extensionName}.json
    default