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:
the contribution will not be created necessarily before a text model is attached. Normally, a contribution is created so early, at a point when the editor has no models. So it is safe for a contribution to simply use editor.onDidChangeModel to check if the contribution needs to do anything. When being instantiated later, it is possible that the contribution will be created at a time when the editor already has a model, so the contribution should be prepared to deal with that in the ctor.
if a contribution needs to be activated via editor events (pasting, typing, mouse events), then most likely you can use EditorContributionInstantiation.BeforeFirstInteraction.
if a contribution is mostly driven by actions or commands, then the contribution will be instantiated when the first action that needs it is executed, so it is safe to use EditorContributionInstantiation.Eventually.
if a contribution is only driven by actions or commands, it is safe to use EditorContributionInstantiation.Lazy.
Anyways, here's the remaining list of contributions for which I wasn't sure what would be correct:
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 useEditorContributionInstantiation
. If a contribution uses eager, a reason should be written as a comment next to it. There are multiple options available:Some things to keep in mind when changing an editor contribution to something else than
EditorContributionInstantiation.Eager
:editor.onDidChangeModel
to check if the contribution needs to do anything. When being instantiated later, it is possible that the contribution will be created at a time when the editor already has a model, so the contribution should be prepared to deal with that in the ctor.EditorContributionInstantiation.BeforeFirstInteraction
.EditorContributionInstantiation.Eventually
.EditorContributionInstantiation.Lazy
.Anyways, here's the remaining list of contributions for which I wasn't sure what would be correct: