mirror of
https://github.com/Microsoft/vscode
synced 2024-10-02 17:32:41 +00:00
Fix #173869 marking active line for code elements too in markdown preview
This commit is contained in:
parent
646de5e063
commit
5b79b91838
|
@ -9,7 +9,7 @@ export class ActiveLineMarker {
|
|||
|
||||
onDidChangeTextEditorSelection(line: number, documentVersion: number) {
|
||||
const { previous } = getElementsForSourceLine(line, documentVersion);
|
||||
this._update(previous && previous.element);
|
||||
this._update(previous && (previous.codeElement || previous.element));
|
||||
}
|
||||
|
||||
_update(before: HTMLElement | undefined) {
|
||||
|
@ -22,13 +22,14 @@ export class ActiveLineMarker {
|
|||
if (!element) {
|
||||
return;
|
||||
}
|
||||
element.className = element.className.replace(/\bcode-active-line\b/g, '');
|
||||
element.classList.toggle('code-active-line', false);
|
||||
}
|
||||
|
||||
_markActiveElement(element: HTMLElement | undefined) {
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
element.className += ' code-active-line';
|
||||
|
||||
element.classList.toggle('code-active-line', true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ const codeLineClass = 'code-line';
|
|||
export interface CodeLineElement {
|
||||
element: HTMLElement;
|
||||
line: number;
|
||||
codeElement?: HTMLElement;
|
||||
}
|
||||
|
||||
const getCodeLineElements = (() => {
|
||||
|
@ -27,9 +28,9 @@ const getCodeLineElements = (() => {
|
|||
}
|
||||
|
||||
if (element.tagName === 'CODE' && element.parentElement && element.parentElement.tagName === 'PRE') {
|
||||
// Fenched code blocks are a special case since the `code-line` can only be marked on
|
||||
// Fenced code blocks are a special case since the `code-line` can only be marked on
|
||||
// the `<code>` element and not the parent `<pre>` element.
|
||||
cachedElements.push({ element: element.parentElement as HTMLElement, line });
|
||||
cachedElements.push({ element: element.parentElement as HTMLElement, line: line, codeElement: element as HTMLElement });
|
||||
} else if (element.tagName === 'UL' || element.tagName === 'OL') {
|
||||
// Skip adding list elements since the first child has the same code line (and should be preferred)
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue