Support setting the layer of a decoration

Fixes #3778
This commit is contained in:
Daniel Imms
2022-05-12 10:51:11 -07:00
parent bc4158c9b8
commit 7b4423819e
10 changed files with 62 additions and 8 deletions
+2 -2
View File
@@ -64,13 +64,13 @@ export class DecorationService extends Disposable implements IDecorationService
return this._decorations.getKeyIterator(line);
}
public *getDecorationsAtCell(x: number, line: number): IterableIterator<IInternalDecoration> {
public *getDecorationsAtCell(x: number, line: number, layer?: 'bottom' | 'top'): IterableIterator<IInternalDecoration> {
let xmin = 0;
let xmax = 0;
for (const d of this._decorations.getKeyIterator(line)) {
xmin = d.options.x ?? 0;
xmax = xmin + (d.options.width ?? 1);
if (x >= xmin && x < xmax) {
if (x >= xmin && x < xmax && (!layer || (d.options.layer ?? 'bottom') === layer)) {
yield d;
}
}
+1 -1
View File
@@ -312,7 +312,7 @@ export interface IDecorationService extends IDisposable {
/** Iterates over the decorations at a line (in no particular order). */
getDecorationsAtLine(line: number): IterableIterator<IInternalDecoration>;
/** Iterates over the decorations at a cell (in no particular order). */
getDecorationsAtCell(x: number, line: number): IterableIterator<IInternalDecoration>;
getDecorationsAtCell(x: number, line: number, layer?: 'bottom' | 'top'): IterableIterator<IInternalDecoration>;
}
export interface IInternalDecoration extends IDecoration {
readonly options: IDecorationOptions;