Skip to content

Commit 515f4f2

Browse files
committed
Performance improvements
1 parent 218e2a0 commit 515f4f2

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "elastic-docs-v3-utilities",
33
"displayName": "Elastic Docs Utilities",
44
"description": "Utilities for Elastic Docs authoring",
5-
"version": "0.11.12",
5+
"version": "0.11.13",
66
"publisher": "Elastic",
77
"repository": {
88
"type": "git",
@@ -16,8 +16,7 @@
1616
],
1717
"icon": "images/icon.png",
1818
"activationEvents": [
19-
"onLanguage:markdown",
20-
"onStartupFinished"
19+
"onLanguage:markdown"
2120
],
2221
"main": "./out/extension.js",
2322
"browser": "./out/extension-web.js",

src/extension.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,17 @@ export function activate(context: vscode.ExtensionContext): void {
247247
function applyColorCustomizations(): void {
248248
const config = vscode.workspace.getConfiguration('editor');
249249
const currentCustomizations = config.get('tokenColorCustomizations') as Record<string, unknown> || {};
250+
const existingRules = (currentCustomizations.textMateRules as Array<{ scope?: string }>) || [];
251+
252+
// Check if our rules are already applied by looking for a known elastic scope
253+
const elasticRulesAlreadyApplied = existingRules.some(
254+
rule => rule.scope && rule.scope.includes('.elastic')
255+
);
256+
257+
if (elasticRulesAlreadyApplied) {
258+
// Rules already exist, skip the expensive settings write
259+
return;
260+
}
250261

251262
// Define our custom color rules
252263
const elasticRules = [
@@ -327,11 +338,9 @@ function applyColorCustomizations(): void {
327338
}
328339
];
329340

330-
// Merge with existing rules
331-
const existingRules = (currentCustomizations.textMateRules as unknown[]) || [];
341+
// Merge with existing rules and apply (only on first activation)
332342
const newRules = [...existingRules, ...elasticRules];
333343

334-
// Apply the customizations
335344
config.update('tokenColorCustomizations', {
336345
...currentCustomizations,
337346
textMateRules: newRules

0 commit comments

Comments
 (0)