Skip to content

Commit

Permalink
vscode: allow to pass max-delay to debounce info, defaults to min^2 m…
Browse files Browse the repository at this point in the history
…illis, microsoft/vscode#140557, fyi @alexdima

Commit: f9e91209d439cec71fee9dfa6e56c7a1aa1af5d2
  • Loading branch information
Johannes Rieken authored and sourcegraph-bot committed Jan 24, 2022
1 parent ea46a4b commit 16404d7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions vscode/src/vs/editor/common/services/languageFeatureDebounce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface ILanguageFeatureDebounceService {

readonly _serviceBrand: undefined;

for(feature: LanguageFeatureRegistry<object>, debugName: string, config?: { min?: number, salt?: string }): IFeatureDebounceInformation;
for(feature: LanguageFeatureRegistry<object>, debugName: string, config?: { min?: number, max?: number, salt?: string }): IFeatureDebounceInformation;
}

export interface IFeatureDebounceInformation {
Expand Down Expand Up @@ -51,7 +51,7 @@ class FeatureDebounceInformation implements IFeatureDebounceInformation {
private readonly _registry: LanguageFeatureRegistry<object>,
private readonly _default: number,
private readonly _min: number,
private readonly _max: number = Number.MAX_SAFE_INTEGER,
private readonly _max: number,
) { }

private _key(model: ITextModel): string {
Expand Down Expand Up @@ -103,8 +103,9 @@ export class LanguageFeatureDebounceService implements ILanguageFeatureDebounceS

}

for(feature: LanguageFeatureRegistry<object>, name: string, config?: { min?: number, key?: string }): IFeatureDebounceInformation {
for(feature: LanguageFeatureRegistry<object>, name: string, config?: { min?: number, max?: number, key?: string }): IFeatureDebounceInformation {
const min = config?.min ?? 50;
const max = config?.max ?? min ** 2;
const extra = config?.key ?? undefined;
const key = `${IdentityHash.of(feature)},${min}${extra ? ',' + extra : ''}`;
let info = this._data.get(key);
Expand All @@ -114,7 +115,8 @@ export class LanguageFeatureDebounceService implements ILanguageFeatureDebounceS
name,
feature,
(this._overallAverage() | 0) || (min * 1.5), // default is overall default or derived from min-value
min
min,
max
);
this._data.set(key, info);
}
Expand Down

0 comments on commit 16404d7

Please sign in to comment.