Skip to content

Commit

Permalink
fix(highlight): rendering all cells
Browse files Browse the repository at this point in the history
Should preserve cells with hlId 0 for clearing highlights
  • Loading branch information
xiyaowong committed Nov 14, 2023
1 parent c5178d1 commit 84344a5
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions src/highlight_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,25 +282,19 @@ export class HighlightProvider implements Disposable {
}
}
}
// combine eol cells that have the same hlId
// Combine EOL cells that have the same hlId
// However, preserve cells with hlId 0 for clearing highlights
const finalEolCells: ValidCell[] = [];
if (eolCells.length > 1) {
let hlId = 0;
for (const [idx, cell] of eolCells.entries()) {
if (idx > 0 && cell.hlId === hlId) {
finalEolCells[finalEolCells.length - 1].text += cell.text;
} else {
finalEolCells.push(cell);
}
hlId = cell.hlId;
}
}
// Clearing cells without actual function used to fill the screen
if (finalEolCells.length) {
const last = finalEolCells[finalEolCells.length - 1];
if (last.text.length > 100 && last.text.trim().length === 0) {
finalEolCells.pop();
let hlId = 0;
for (const cell of eolCells) {
if (cell.hlId === 0) {
finalEolCells.push(cell);
} else if (cell.hlId === hlId && finalEolCells.length) {
finalEolCells[finalEolCells.length - 1].text += cell.text;
} else {
finalEolCells.push(cell);
}
hlId = cell.hlId;
}
validCells.push(...finalEolCells);
}
Expand Down

0 comments on commit 84344a5

Please sign in to comment.