提交 4e91a74c 编写于 作者: M Matt Bierner 提交者: GitHub

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
上级 7363c243
......@@ -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)},
......
......@@ -106,7 +106,7 @@ CommandsRegistry.registerCommand('_workbench.htmlPreview.postMessage', (accessor
const activePreviews = accessor.get(IWorkbenchEditorService).getVisibleEditors()
.filter(c => c instanceof HtmlPreviewPart)
.map(e => e as HtmlPreviewPart)
.filter(e => e.model.uri.scheme === uri.scheme && e.model.uri.path === uri.path);
.filter(e => e.model.uri.scheme === uri.scheme && e.model.uri.fsPath === uri.fsPath);
for (const preview of activePreviews) {
preview.sendMessage(message);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册