提交 7023d988 编写于 作者: M Matt Bierner

Fix double click to switch to editor

上级 c26185b9
......@@ -296,7 +296,7 @@
const offset = event.pageY;
const line = getEditorLineNumberForPageOffset(offset);
if (!isNaN(line)) {
postCommand('_markdown.didClick', [settings.source, line]);
postMessage('didClick', { line });
}
});
......@@ -334,7 +334,7 @@
} else {
const line = getEditorLineNumberForPageOffset(window.scrollY);
if (!isNaN(line)) {
postMessage('revealLine', { source: settings.source, line });
postMessage('revealLine', { line });
}
}
}, 50));
......
......@@ -65,6 +65,10 @@ class MarkdownPreview {
this.onDidScrollPreview(e.body.line);
break;
case 'didClick':
this.onDidClickPreview(e.body.line);
break;
}
}, null, this.disposables);
......@@ -269,6 +273,17 @@ class MarkdownPreview {
vscode.TextEditorRevealType.AtTop);
}
}
private async onDidClickPreview(line: number): Promise<void> {
for (const visibleEditor of vscode.window.visibleTextEditors) {
if (this.isPreviewOf(visibleEditor.document.uri)) {
const editor = await vscode.window.showTextDocument(visibleEditor.document, visibleEditor.viewColumn);
const position = new vscode.Position(line, 0);
editor.selection = new vscode.Selection(position, position);
return;
}
}
}
}
export interface PreviewSettings {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册