Skip to content

Commit

Permalink
hiddenAreasIds -> hiddenAreasDecorationIds, fixes leaking decorations…
Browse files Browse the repository at this point in the history
… when lines are reconstructed.
  • Loading branch information
hediet committed Nov 9, 2021
1 parent 1abc24d commit ace5163
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/vs/editor/common/viewModel/viewModelLines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class ViewModelLinesFromProjectedModel implements IViewModelLines {
*/
private projectedModelLineLineCounts!: ConstantTimePrefixSumComputer;

private hiddenAreasIds!: string[];
private hiddenAreasDecorationIds!: string[];

constructor(
editorId: number,
Expand Down Expand Up @@ -105,7 +105,7 @@ export class ViewModelLinesFromProjectedModel implements IViewModelLines {
}

public dispose(): void {
this.hiddenAreasIds = this.model.deltaDecorations(this.hiddenAreasIds, []);
this.hiddenAreasDecorationIds = this.model.deltaDecorations(this.hiddenAreasDecorationIds, []);
}

public createCoordinatesConverter(): ICoordinatesConverter {
Expand All @@ -116,7 +116,7 @@ export class ViewModelLinesFromProjectedModel implements IViewModelLines {
this.modelLineProjections = [];

if (resetHiddenAreas) {
this.hiddenAreasIds = [];
this.hiddenAreasDecorationIds = this.model.deltaDecorations(this.hiddenAreasDecorationIds, []);
}

const linesContent = this.model.getLinesContent();
Expand All @@ -133,7 +133,7 @@ export class ViewModelLinesFromProjectedModel implements IViewModelLines {

let values: number[] = [];

let hiddenAreas = this.hiddenAreasIds.map((areaId) => this.model.getDecorationRange(areaId)!).sort(Range.compareRangesUsingStarts);
let hiddenAreas = this.hiddenAreasDecorationIds.map((areaId) => this.model.getDecorationRange(areaId)!).sort(Range.compareRangesUsingStarts);
let hiddenAreaStart = 1, hiddenAreaEnd = 0;
let hiddenAreaIdx = -1;
let nextLineNumberToUpdateHiddenArea = (hiddenAreaIdx + 1 < hiddenAreas.length) ? hiddenAreaEnd + 1 : lineCount + 2;
Expand All @@ -160,17 +160,17 @@ export class ViewModelLinesFromProjectedModel implements IViewModelLines {
}

public getHiddenAreas(): Range[] {
return this.hiddenAreasIds.map((decId) => {
return this.model.getDecorationRange(decId)!;
});
return this.hiddenAreasDecorationIds.map(
(decId) => this.model.getDecorationRange(decId)!
);
}

public setHiddenAreas(_ranges: Range[]): boolean {
const validatedRanges = _ranges.map(r => this.model.validateRange(r));
let newRanges = normalizeLineRanges(validatedRanges);

// BEGIN TODO@Martin: Please stop calling this method on each model change!
let oldRanges = this.hiddenAreasIds.map((areaId) => this.model.getDecorationRange(areaId)!).sort(Range.compareRangesUsingStarts);
let oldRanges = this.hiddenAreasDecorationIds.map((areaId) => this.model.getDecorationRange(areaId)!).sort(Range.compareRangesUsingStarts);

if (newRanges.length === oldRanges.length) {
let hasDifference = false;
Expand All @@ -194,7 +194,7 @@ export class ViewModelLinesFromProjectedModel implements IViewModelLines {
});
}

this.hiddenAreasIds = this.model.deltaDecorations(this.hiddenAreasIds, newDecorations);
this.hiddenAreasDecorationIds = this.model.deltaDecorations(this.hiddenAreasDecorationIds, newDecorations);

let hiddenAreas = newRanges;
let hiddenAreaStart = 1, hiddenAreaEnd = 0;
Expand Down

0 comments on commit ace5163

Please sign in to comment.