mirror of
https://github.com/Microsoft/vscode
synced 2024-10-02 09:18:59 +00:00
f4bf1f30a2
Fixes #155552 For lists, the outer ul/ol always has the same source line as the first element in the list. We should prefer using the first element in the list when highlighting the active line This also fixes a bug where scroll sync would stop working if you added lines to the doc. This was caused by `lineCount` getting out of sync as the document is being updated. I've removed this state and made the reveal logic more robust instead
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
export interface PreviewSettings {
|
|
readonly source: string;
|
|
readonly line?: number;
|
|
readonly fragment?: string;
|
|
readonly selectedLine?: number;
|
|
|
|
readonly scrollPreviewWithEditor?: boolean;
|
|
readonly scrollEditorWithPreview: boolean;
|
|
readonly disableSecurityWarnings: boolean;
|
|
readonly doubleClickToSwitchToEditor: boolean;
|
|
readonly webviewResourceRoot: string;
|
|
}
|
|
|
|
export function getData<T = {}>(key: string): T {
|
|
const element = document.getElementById('vscode-markdown-preview-data');
|
|
if (element) {
|
|
const data = element.getAttribute(key);
|
|
if (data) {
|
|
return JSON.parse(data);
|
|
}
|
|
}
|
|
|
|
throw new Error(`Could not load data for ${key}`);
|
|
}
|
|
|
|
export class SettingsManager {
|
|
private _settings: PreviewSettings = getData('data-settings');
|
|
|
|
public get settings(): PreviewSettings {
|
|
return this._settings;
|
|
}
|
|
|
|
public updateSettings(newSettings: PreviewSettings) {
|
|
this._settings = newSettings;
|
|
}
|
|
}
|