fix hover underline
This commit is contained in:
@@ -49,7 +49,18 @@ export class DomRendererRowFactory {
|
||||
this._columnSelectMode = columnSelectMode;
|
||||
}
|
||||
|
||||
public createRow(lineData: IBufferLine, row: number, isCursorRow: boolean, cursorStyle: string | undefined, cursorX: number, cursorBlink: boolean, cellWidth: number, cols: number, cellMap: Int16Array, metrics: Uint8Array): DocumentFragment {
|
||||
public createRow(
|
||||
lineData: IBufferLine,
|
||||
row: number,
|
||||
isCursorRow: boolean,
|
||||
cursorStyle: string | undefined,
|
||||
cursorX: number,
|
||||
cursorBlink: boolean,
|
||||
cellWidth: number,
|
||||
cols: number,
|
||||
metrics: Uint8Array,
|
||||
linkState: Uint8Array
|
||||
): DocumentFragment {
|
||||
// NOTE: `cellMap` maps cell positions to a span element index in a row.
|
||||
// All positions should be updated, even skipped ones after wide chars or left overs at the end,
|
||||
// otherwise the mouse hover logic might mark the wrong elements as underlined.
|
||||
@@ -71,7 +82,6 @@ export class DomRendererRowFactory {
|
||||
}
|
||||
|
||||
const colors = this._themeService.colors;
|
||||
let elemIndex = -1;
|
||||
|
||||
let charElement: HTMLSpanElement | undefined;
|
||||
let cellAmount = 0;
|
||||
@@ -79,6 +89,9 @@ export class DomRendererRowFactory {
|
||||
let oldBg = 0;
|
||||
let oldFg = 0;
|
||||
let oldExt = 0;
|
||||
let oldLinkHover: number | boolean = false;
|
||||
|
||||
const isHover = linkState[0];
|
||||
|
||||
let x = 0;
|
||||
for (; x < lineLength; x++) {
|
||||
@@ -86,9 +99,7 @@ export class DomRendererRowFactory {
|
||||
let width = this._workCell.getWidth();
|
||||
|
||||
// The character to the left is a wide character, drawing is owned by the char at x-1
|
||||
// still have to update cellMap with current element index
|
||||
if (width === 0) {
|
||||
cellMap[x] = elemIndex;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -126,6 +137,7 @@ export class DomRendererRowFactory {
|
||||
const isCursorCell = isCursorRow && x === cursorX;
|
||||
const cc = cell.getCode();
|
||||
const isCombined = cell.isCombined();
|
||||
const isLinkHover = isHover && x >= linkState[1] && x <= linkState[2];
|
||||
|
||||
if (!charElement) {
|
||||
charElement = this._document.createElement('span');
|
||||
@@ -144,6 +156,7 @@ export class DomRendererRowFactory {
|
||||
&& cc < 1424 && !metrics[cc]
|
||||
&& !isInSelection
|
||||
&& !isCursorCell
|
||||
&& isLinkHover === oldLinkHover
|
||||
) {
|
||||
let c = cell.isInvisible() ? WHITESPACE_CELL_CHAR : (cell.getChars() || WHITESPACE_CELL_CHAR);
|
||||
if (c === ' ' && (cell.isUnderline() || cell.isOverline())) {
|
||||
@@ -154,6 +167,7 @@ export class DomRendererRowFactory {
|
||||
oldBg = cell.bg;
|
||||
oldFg = cell.fg;
|
||||
oldExt = cell.extended.ext;
|
||||
oldLinkHover = isLinkHover;
|
||||
continue;
|
||||
} else {
|
||||
if (cellAmount) {
|
||||
@@ -168,6 +182,7 @@ export class DomRendererRowFactory {
|
||||
oldBg = cell.bg;
|
||||
oldFg = cell.fg;
|
||||
oldExt = cell.extended.ext;
|
||||
oldLinkHover = isLinkHover;
|
||||
|
||||
|
||||
|
||||
@@ -256,6 +271,10 @@ export class DomRendererRowFactory {
|
||||
charElement.classList.add(STRIKETHROUGH_CLASS);
|
||||
}
|
||||
|
||||
if (isLinkHover) {
|
||||
charElement.style.textDecoration = 'underline';
|
||||
}
|
||||
|
||||
let fg = cell.getFgColor();
|
||||
let fgColorMode = cell.getFgColorMode();
|
||||
let bg = cell.getBgColor();
|
||||
@@ -381,10 +400,7 @@ export class DomRendererRowFactory {
|
||||
charElement.textContent = text;
|
||||
}
|
||||
|
||||
|
||||
fragment.appendChild(charElement);
|
||||
cellMap[x] = ++elemIndex;
|
||||
|
||||
x = lastCharX;
|
||||
}
|
||||
|
||||
@@ -394,12 +410,6 @@ export class DomRendererRowFactory {
|
||||
charElement.style.width = `${cellWidth * cellAmount}px`;
|
||||
}
|
||||
|
||||
// since the loop above might exit early not handling all cells,
|
||||
// also set remaining cell positions to last element index
|
||||
if (x < cols - 1) {
|
||||
cellMap.subarray(x).fill(++elemIndex);
|
||||
}
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user