fix(markdown): keep cross-file link destination focused (#8194)

#8172 recorded a cross-file Markdown preview link's origin by moving the source editor's caret before opening the destination. In Split mode that selection pulled focus back into the source editor while the open was still in progress, so the new destination tab was deactivated at once. In Split mode the clicked line is now recorded in navigation history directly, without touching the caret; Preview Only keeps using the hidden editor's caret, which is the reader's position.

Co-authored-by: arookieofc-ai <[email protected]>
Цей коміт міститься в:
arookieofc-ai[bot]таarookieofc-ai authored and GitHub committed 2026-12-05 17:19:25 +08:00
1 джерело 32fa8b60f8
коміт eecd78aee5
2 files changed
+11 -1

No files matched your search

+7
Переглянути файл
@@ -1242,6 +1242,13 @@ export class EditorController implements SlotHost {
return { path: slot.model.path, ...loc, ...(paneId ? { paneId } : {}) };
}
/** Records a click position in `slot` without moving its caret or focus (Markdown preview cross-file links). */
recordClickedLine(slot: EditorSlot, line: number) {
if (this.navSuppress > 0 || slot.disposed) return;
const paneId = this.locateTab(slot.tabId)?.paneId;
this.nav.update({ path: slot.model.path, line, col: 0, ...(paneId ? { paneId } : {}) }, true);
}
/** `navigation`: the caret got here by a navigation (see NavigationHistory.update). */
private recordNav(slot: EditorSlot, navigation = false, preferCaret = false) {
if (this.navSuppress > 0 || slot.disposed) return;
+4 -1
Переглянути файл
@@ -1545,7 +1545,10 @@ function MarkdownPreview({
else if (target.path === filePath && target.anchor) scrollTo(target.anchor);
else
void (async () => {
if (originLine !== null) recordPreviewLine(originLine, "select.pointer", false);
if (originLine !== null) {
if (sync && slot) editorController().recordClickedLine(slot, originLine);
else recordPreviewLine(originLine, "select.pointer", false);
}
const docsTarget =
isMdxPath(filePath) && rawHref.trim().startsWith("/")
? await resolveDocsRootDocLink(filePath, rawHref, allowedRoots)