mirror of
https://github.com/coder/code-server.git
synced 2025-07-28 20:43:24 +08:00
Merge commit 'be3e8236086165e5e45a5a10783823874b3f3ebd' as 'lib/vscode'
This commit is contained in:
@ -0,0 +1,34 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { getElementsForSourceLine } from './scroll-sync';
|
||||
|
||||
export class ActiveLineMarker {
|
||||
private _current: any;
|
||||
|
||||
onDidChangeTextEditorSelection(line: number) {
|
||||
const { previous } = getElementsForSourceLine(line);
|
||||
this._update(previous && previous.element);
|
||||
}
|
||||
|
||||
_update(before: HTMLElement | undefined) {
|
||||
this._unmarkActiveElement(this._current);
|
||||
this._markActiveElement(before);
|
||||
this._current = before;
|
||||
}
|
||||
|
||||
_unmarkActiveElement(element: HTMLElement | undefined) {
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
element.className = element.className.replace(/\bcode-active-line\b/g, '');
|
||||
}
|
||||
|
||||
_markActiveElement(element: HTMLElement | undefined) {
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
element.className += ' code-active-line';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user