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:
Matt Bierner
2017-02-06 10:19:45 -08:00
committed by GitHub
parent 7363c243f2
commit 4e91a74c6f
3 changed files with 5 additions and 5 deletions

View File

@@ -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));

View File

@@ -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)},