mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 01:58:53 +01:00
Fix Markdown Scroll Sync For Windows Path Casing (#20064)
**Bug** Scroll sync not working for some users on windows **Fix** Root cause seems to be that windows drive/path cases can sometimes differ between preview and editor document. Adds a equality check based on `fsPath` as well
This commit is contained in:
@@ -44,7 +44,7 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
context.subscriptions.push(vscode.commands.registerCommand('_markdown.revealLine', (uri, line) => {
|
||||
const sourceUri = vscode.Uri.parse(decodeURIComponent(uri));
|
||||
vscode.window.visibleTextEditors
|
||||
.filter(editor => editor.document.uri.path === sourceUri.path)
|
||||
.filter(editor => isMarkdownFile(editor.document) && editor.document.uri.fsPath === sourceUri.fsPath)
|
||||
.forEach(editor => {
|
||||
const sourceLine = Math.floor(line);
|
||||
const text = editor.document.getText(new vscode.Range(sourceLine, 0, sourceLine + 1, 0));
|
||||
@@ -82,10 +82,10 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
}
|
||||
}
|
||||
};
|
||||
if (vscode.window.activeTextEditor && vscode.window.activeTextEditor.document.uri.path === args.path) {
|
||||
if (vscode.window.activeTextEditor && isMarkdownFile(vscode.window.activeTextEditor.document) && vscode.window.activeTextEditor.document.uri.fsPath === args.fsPath) {
|
||||
return tryRevealLine(vscode.window.activeTextEditor);
|
||||
} else {
|
||||
const resource = vscode.Uri.file(args.path);
|
||||
const resource = vscode.Uri.file(args.fsPath);
|
||||
vscode.workspace.openTextDocument(resource)
|
||||
.then(vscode.window.showTextDocument)
|
||||
.then(tryRevealLine, _ => vscode.commands.executeCommand('vscode.open', resource));
|
||||
|
||||
@@ -117,7 +117,7 @@ export class MDDocumentContentProvider implements vscode.TextDocumentContentProv
|
||||
${body}
|
||||
<script>
|
||||
window.initialData = {
|
||||
source: "${encodeURIComponent(sourceUri.scheme + '://' + sourceUri.path)}",
|
||||
source: "${encodeURIComponent(sourceUri.toString(true))}",
|
||||
line: ${initialLine},
|
||||
scrollPreviewWithEditorSelection: ${!!markdownConfig.get('preview.scrollPreviewWithEditorSelection', true)},
|
||||
scrollEditorWithPreview: ${!!markdownConfig.get('preview.scrollEditorWithPreview', true)},
|
||||
|
||||
Reference in New Issue
Block a user