Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/codeEditor/electron-browser/displayChangeRemeasureFonts.ts
5281 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { ThrottledDelayer } from '../../../../base/common/async.js';
7
import { Disposable } from '../../../../base/common/lifecycle.js';
8
import { FontMeasurements } from '../../../../editor/browser/config/fontMeasurements.js';
9
import { INativeHostService } from '../../../../platform/native/common/native.js';
10
import { Registry } from '../../../../platform/registry/common/platform.js';
11
import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry } from '../../../common/contributions.js';
12
import { LifecyclePhase } from '../../../services/lifecycle/common/lifecycle.js';
13
14
class DisplayChangeRemeasureFonts extends Disposable implements IWorkbenchContribution {
15
16
private readonly _delayer = this._register(new ThrottledDelayer(2000));
17
18
constructor(
19
@INativeHostService nativeHostService: INativeHostService
20
) {
21
super();
22
23
this._register(nativeHostService.onDidChangeDisplay(() => {
24
this._delayer.trigger(() => {
25
FontMeasurements.clearAllFontInfos();
26
return Promise.resolve();
27
});
28
}));
29
}
30
}
31
32
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(DisplayChangeRemeasureFonts, LifecyclePhase.Eventually);
33
34