Skip to content

Commit

Permalink
Fixes #45011: Eliminate duplicate decorations (if they intersect mult…
Browse files Browse the repository at this point in the history
…iple visible ranges)
  • Loading branch information
alexdima committed Sep 17, 2018
1 parent a46554c commit 872e0fe
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/vs/editor/common/viewModel/splitLinesCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,35 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
reqStart = null;
}

return result;
result.sort((a, b) => {
const res = Range.compareRangesUsingStarts(a.range, b.range);
if (res === 0) {
if (a.id < b.id) {
return -1;
}
if (a.id > b.id) {
return 1;
}
return 0;
}
return res;
});

// Eliminate duplicate decorations that might have intersected our visible ranges multiple times
let finalResult: IModelDecoration[] = [], finalResultLen = 0;
let prevDecId: string = null;
for (let i = 0, len = result.length; i < len; i++) {
const dec = result[i];
const decId = dec.id;
if (prevDecId === decId) {
// skip
continue;
}
prevDecId = decId;
finalResult[finalResultLen++] = dec;
}

return finalResult;
}
}

Expand Down

0 comments on commit 872e0fe

Please sign in to comment.