Skip to content

Commit 7276027

Browse files
authored
Merge pull request #4651 from jerch/fix_4642
fix decorations on DOM renderer
2 parents 0224317 + 0366aa2 commit 7276027

File tree

2 files changed

+31
-22
lines changed

2 files changed

+31
-22
lines changed

src/browser/renderer/dom/DomRendererRowFactory.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ export class DomRendererRowFactory {
131131
const isCursorCell = isCursorRow && x === cursorX;
132132
const isLinkHover = hasHover && x >= linkStart && x <= linkEnd;
133133

134+
let isDecorated = false;
135+
this._decorationService.forEachDecorationAtCell(x, row, undefined, d => {
136+
isDecorated = true;
137+
});
138+
134139
// get chars to render for this cell
135140
let chars = cell.getChars() || WHITESPACE_CELL_CHAR;
136141
if (chars === ' ' && (cell.isUnderline() || cell.isOverline())) {
@@ -160,6 +165,7 @@ export class DomRendererRowFactory {
160165
&& spacing === oldSpacing
161166
&& !isCursorCell
162167
&& !isJoined
168+
&& !isDecorated
163169
) {
164170
// no span alterations, thus only account chars skipping all code below
165171
text += chars;
@@ -386,7 +392,7 @@ export class DomRendererRowFactory {
386392
}
387393

388394
// exclude conditions for cell merging - never merge these
389-
if (!isCursorCell && !isInSelection && !isJoined) {
395+
if (!isCursorCell && !isInSelection && !isJoined && !isDecorated) {
390396
cellAmount++;
391397
} else {
392398
charElement.textContent = text;

src/common/SortedList.ts

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class SortedList<T> {
2828
this._array.push(value);
2929
return;
3030
}
31-
i = this._search(this._getKey(value), 0, this._array.length - 1);
31+
i = this._search(this._getKey(value));
3232
this._array.splice(i, 0, value);
3333
}
3434

@@ -40,7 +40,7 @@ export class SortedList<T> {
4040
if (key === undefined) {
4141
return false;
4242
}
43-
i = this._search(key, 0, this._array.length - 1);
43+
i = this._search(key);
4444
if (i === -1) {
4545
return false;
4646
}
@@ -60,7 +60,7 @@ export class SortedList<T> {
6060
if (this._array.length === 0) {
6161
return;
6262
}
63-
i = this._search(key, 0, this._array.length - 1);
63+
i = this._search(key);
6464
if (i < 0 || i >= this._array.length) {
6565
return;
6666
}
@@ -76,7 +76,7 @@ export class SortedList<T> {
7676
if (this._array.length === 0) {
7777
return;
7878
}
79-
i = this._search(key, 0, this._array.length - 1);
79+
i = this._search(key);
8080
if (i < 0 || i >= this._array.length) {
8181
return;
8282
}
@@ -92,23 +92,26 @@ export class SortedList<T> {
9292
return this._array.values();
9393
}
9494

95-
private _search(key: number, min: number, max: number): number {
96-
if (max < min) {
97-
return min;
98-
}
99-
let mid = Math.floor((min + max) / 2);
100-
const midKey = this._getKey(this._array[mid]);
101-
if (midKey > key) {
102-
return this._search(key, min, mid - 1);
103-
}
104-
if (midKey < key) {
105-
return this._search(key, mid + 1, max);
106-
}
107-
// Value found! Since keys can be duplicates, move the result index back to the lowest index
108-
// that matches the key.
109-
while (mid > 0 && this._getKey(this._array[mid - 1]) === key) {
110-
mid--;
95+
private _search(key: number): number {
96+
let min = 0;
97+
let max = this._array.length - 1;
98+
while (max >= min) {
99+
let mid = (min + max) >> 1;
100+
const midKey = this._getKey(this._array[mid]);
101+
if (midKey > key) {
102+
max = mid - 1;
103+
} else if (midKey < key) {
104+
min = mid + 1;
105+
} else {
106+
// key in list, walk to lowest duplicate
107+
while (mid > 0 && this._getKey(this._array[mid - 1]) === key) {
108+
mid--;
109+
}
110+
return mid;
111+
}
111112
}
112-
return mid;
113+
// key not in list
114+
// still return closest min (also used as insert position)
115+
return min;
113116
}
114117
}

0 commit comments

Comments
 (0)