Skip to content

Commit 610c5b0

Browse files
authored
Add a throttled delayer to avoid reacting to display changes too often (#282977)
Add a throttled delayer to avoid reacting to display changes too often (closes #174041)
1 parent a1b2b62 commit 610c5b0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/vs/workbench/contrib/codeEditor/electron-browser/displayChangeRemeasureFonts.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import { ThrottledDelayer } from '../../../../base/common/async.js';
67
import { Disposable } from '../../../../base/common/lifecycle.js';
78
import { FontMeasurements } from '../../../../editor/browser/config/fontMeasurements.js';
89
import { INativeHostService } from '../../../../platform/native/common/native.js';
@@ -12,13 +13,18 @@ import { LifecyclePhase } from '../../../services/lifecycle/common/lifecycle.js'
1213

1314
class DisplayChangeRemeasureFonts extends Disposable implements IWorkbenchContribution {
1415

16+
private readonly _delayer = this._register(new ThrottledDelayer(2000));
17+
1518
constructor(
1619
@INativeHostService nativeHostService: INativeHostService
1720
) {
1821
super();
1922

2023
this._register(nativeHostService.onDidChangeDisplay(() => {
21-
FontMeasurements.clearAllFontInfos();
24+
this._delayer.trigger(() => {
25+
FontMeasurements.clearAllFontInfos();
26+
return Promise.resolve();
27+
});
2228
}));
2329
}
2430
}

0 commit comments

Comments
 (0)