Skip to content

Commit

Permalink
fix: limit decorations to prevent editor slowdown (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skn0tt authored Jan 13, 2025
1 parent 4068938 commit 179f19d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,9 @@ export class Extension implements RunHooks {
}
});
}

if (completedDecorations.length > 1000) // too many decorations slow down the editor
break;
}

editor.setDecorations(this._activeStepDecorationType, activeDecorations);
Expand Down
23 changes: 23 additions & 0 deletions tests/decorations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,26 @@ test('should highlight steps while running', async ({ activate }) => {
},
]);
});

test('should limit highlights', async ({ activate }) => {
const { vscode, testController } = await activate({
'playwright.config.js': `module.exports = { testDir: 'tests' }`,
'tests/test.spec.ts': `
import { test, expect } from '@playwright/test';
test('pass', async () => {
for (let i = 0; i < 2000; i++) {
expect(i).toBe(i);
}
});
`,
});

await vscode.openEditors('**/test.spec.ts');
await new Promise(f => testController.onDidChangeTestItem(f));

await testController.run();

const decorationsLog = vscode.window.activeTextEditor.renderDecorations(' ');
const lastState = decorationsLog.substring(decorationsLog.lastIndexOf('------'));
expect(lastState.split('\n').length).toBeLessThan(2000);
});

0 comments on commit 179f19d

Please sign in to comment.