Override a command
- Last UpdatedJul 23, 2024
- 1 minute read
The loading order of IDE extensions is determined by the “Priority” attribute value provided by the extensions in its manifest. Priority ranges from 1 through 999 and higher the priority number, earlier the extension is loaded by the IDE. Following is an example extract from the sample manifest, emphasizing the priority of an IDE extension.
<Snapin TypeId="907162B9-F0AE-40d0-92C9-79E3DAB04D43" Priority="550">
In addition to introducing new commands into the IDE, extensions can also choose to override the behavior of the commands that are defined by the IDE itself and those by other extensions. Overriding a command means changing the behavior of a command and not changing the definition of the actual command. In order to override a command, the extension should make sure that it is loaded after other extensions that are interested in the same command, by providing lower priority. Extensions loaded later have higher preference than the ones loaded before, when it comes to getting a chance at handling commands.
Now, in order to actually override a command behavior (defined by the IDE or other extension) the extension should register the command target, handle command updates and command invocations just the same way as it handles its own commands. The only difference is that it registers the command target for the command, which is defined by the IDE or some other extension instead of its own command. Please see “Handling Commands” section for detailed information on how to handle a command, irrespective of whether the command is defined by the same extension, by the IDE or some other extension.