mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
Make markdown refresh more stable
Fixes #80680 - Always sync the current preview line number with the editor, even when `scrollEditorWithPreview` is false - If the md file is focused and refresh is called, do not try resetting the current line to match the editor file. This mainly effects the case where `scrollEditorWithPreview` is false
This commit is contained in:
@@ -157,20 +157,18 @@ document.addEventListener('click', event => {
|
||||
}
|
||||
}, true);
|
||||
|
||||
if (settings.scrollEditorWithPreview) {
|
||||
window.addEventListener('scroll', throttle(() => {
|
||||
if (scrollDisabled) {
|
||||
scrollDisabled = false;
|
||||
} else {
|
||||
const line = getEditorLineNumberForPageOffset(window.scrollY);
|
||||
if (typeof line === 'number' && !isNaN(line)) {
|
||||
messaging.postMessage('revealLine', { line });
|
||||
state.line = line;
|
||||
vscode.setState(state);
|
||||
}
|
||||
window.addEventListener('scroll', throttle(() => {
|
||||
if (scrollDisabled) {
|
||||
scrollDisabled = false;
|
||||
} else {
|
||||
const line = getEditorLineNumberForPageOffset(window.scrollY);
|
||||
if (typeof line === 'number' && !isNaN(line)) {
|
||||
messaging.postMessage('revealLine', { line });
|
||||
state.line = line;
|
||||
vscode.setState(state);
|
||||
}
|
||||
}, 50));
|
||||
}
|
||||
}
|
||||
}, 50));
|
||||
|
||||
function escapeRegExp(text: string) {
|
||||
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
||||
|
||||
Reference in New Issue
Block a user