Somehow when adding my custom formatter extension for TypeScript to Multiple Formatters, it seems to be loaded twice.
provideDocumentFormattingEdits is called twice as I console.log(), while activate() is called only once.
I wonder why this is happening. It does not happen when loaded directly as default formatter instead of using Multiple Formatters. Even in the most stripped-down version below.
settings.json (workspace - user does not have this setting)
"[typescript]": {
"editor.defaultFormatter": "jota0222.multi-formatter",
"multiFormatter.formatterList": [
"vscode.typescript-language-features",
"undefined_publisher.my-custom-formatter"
],
},
extension.ts
export function activate(context: vscode.ExtensionContext) {
console.log('activate');
vscode.languages.registerDocumentFormattingEditProvider(
[ 'typescript', 'javascript' ]
, {
provideDocumentFormattingEdits(document: vscode.TextDocument): vscode.TextEdit[] {
console.log('provideDocumentFormattingEdits:');
return [];
}
});
}
package.json (extension - parts which may be relevant?)
"engines": {
"vscode": "^1.86.0"
},
"categories": [
"Formatters"
],
"activationEvents": [
"onLanguage:typescript"
],
"contributes": {
},
Somehow when adding my custom formatter extension for TypeScript to Multiple Formatters, it seems to be loaded twice.
provideDocumentFormattingEditsis called twice as Iconsole.log(), whileactivate()is called only once.I wonder why this is happening. It does not happen when loaded directly as default formatter instead of using Multiple Formatters. Even in the most stripped-down version below.
settings.json (workspace - user does not have this setting)
extension.ts
package.json (extension - parts which may be relevant?)