From 06697bddbb37afd12de7598c78bc8d62472f7255 Mon Sep 17 00:00:00 2001 From: Titus Date: Fri, 17 Jul 2026 09:39:48 +0200 Subject: [PATCH] Link picker: refresh Properties view after write (no more go-away-and-back) processFrontMatter updates the file but the open editor's Properties panel lags until metadataCache re-indexes, so a just-linked/unlinked value didn't show until you left and returned. After a link write, re-set the active view's state to force a clean properties re-render (best-effort; the write already succeeded regardless). Captain-verified live. Co-Authored-By: Claude Fable 5 --- Listeners/NoteLinker.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Listeners/NoteLinker.ts b/Listeners/NoteLinker.ts index e46bf65..75ef6e1 100644 --- a/Listeners/NoteLinker.ts +++ b/Listeners/NoteLinker.ts @@ -168,10 +168,30 @@ export class NoteLinker { target[choice.key] = links.length ? links[0] : null; } }); + await this.refreshPropertiesView(file); const label = selected.length ? selected.map((e) => e.name).join(', ') : '(none)'; new Notice(`${choice.label}: ${label}`); } + /** + * Nudge the Properties panel to repaint after a frontmatter write. + * processFrontMatter updates the file, but the open editor's Properties view + * lags until metadataCache re-indexes — so a just-linked/unlinked value doesn't + * show until you leave and return. If the file is open in the active view, + * re-set its view state, which forces a clean re-render of the properties. + */ + private async refreshPropertiesView(file: TFile): Promise { + const view = this.app.workspace.getActiveViewOfType(MarkdownView); + if (!view || view.file?.path !== file.path) return; + try { + const leaf = view.leaf; + const state = leaf.getViewState(); + await leaf.setViewState({ ...state, active: true }); + } catch { + /* refresh is best-effort — the write already succeeded */ + } + } + /** id+name of every element of `target` type in the world (excludes self). */ private async fetchElementsOfType( worldName: string,