Feature: Implement lint rule to eliminate accidental nested updates #7040
Open
Description
Description
Nested updates are never a good idea, so if we find a $function
(or a registerCommand
) that has an embedded editor.update
we should rewrite it to remove the editor.update
. As a companion to this we could add a $defer
or something like that which could be used to provide explicit nested update semantics but I doubt we'll actually find any use case for it.
Impact
Bugs will be avoided, code will be easier to test when the effects of updates happen in a sensible order. Nobody really wants to reason about code that looks like this:
editor.dispatchCommand(COMMAND_A, undefined);
editor.update(() => $b());
editor.dispatchCommand(COMMAND_C, undefined);
that will either execute in A, B, C or A, C, B 🙃 order depending on the context of whether this is called inside of an editor.update
(or command listener) or not.