microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.29k stars 29.31k forks source link

Adopt idle or eager editor contribution instantiation #166969

Closed alexdima closed 1 year ago

alexdima commented 1 year ago

With https://github.com/microsoft/vscode/pull/166966 I went over most editor contributions (50+) and adopted idle value instantiation where I could reason that they would still work correctly. But some editor contributions interact in more complex ways, sometimes with each other, and I wasn't sure. Hence, this issue.

I would like to ask that all registerEditorContribution calls explicitly use EditorContributionInstantiation. If a contribution uses eager, a reason should be written as a comment next to it. There are multiple options available:

export const enum EditorContributionInstantiation {
    /**
     * The contribution is created eagerly when the {@linkcode ICodeEditor} is instantiated.
     * Only Eager contributions can participate in saving or restoring of view state.
     */
    Eager,

    /**
     * The contribution is created at the latest 50ms after the first render after attaching a text model.
     * If the contribution is explicitly requested via `getContribution`, it will be instantiated sooner.
     * If there is idle time available, it will be instantiated sooner.
     */
    AfterFirstRender,

    /**
     * The contribution is created before the editor emits events produced by user interaction (mouse events, keyboard events).
     * If the contribution is explicitly requested via `getContribution`, it will be instantiated sooner.
     * If there is idle time available, it will be instantiated sooner.
     */
    BeforeFirstInteraction,

    /**
     * The contribution is created when there is idle time available, at the latest 5000ms after the editor creation.
     * If the contribution is explicitly requested via `getContribution`, it will be instantiated sooner.
     */
    Eventually,

    /**
     * The contribution is created only when explicitly requested via `getContribution`.
     */
    Lazy,
}

Some things to keep in mind when changing an editor contribution to something else than EditorContributionInstantiation.Eager:

Anyways, here's the remaining list of contributions for which I wasn't sure what would be correct:

bpasero commented 1 year ago

Replacing me with @TylerLeonhardt who took over quick pick.