Renaming a note corrupts a link that sits on the opening line of a %% comment, or on a callout's continuation line inside a list item

Steps to reproduce

  1. Settings > Files and links: turn on Automatically update internal links.
  2. Create a note target (any content).
  3. Create a note A with exactly this content:
%% see [[target]] here
more
%%

after
  1. Create a note B with exactly this content:
1. > [!note] T
> ab cd [[target]] end
  1. Rename target to renamed.
  2. Open A and B in Source mode.

Did you follow the troubleshooting guide?

Yes (reproduced in a fresh vault, no community plugins, default settings apart from step 1).

Expected result

  • A: %% see [[renamed]] here
  • B: > ab cd [[renamed]] end

Actual result

The rename writes the new link at the wrong place and destroys the surrounding text:

  • A: %% se[](renamed.md)]] here (the e [[target is gone, and a broken markdown link is left behind)
  • B: > ab cd [[](renamed.md)end

The cause is visible in the metadata cache: app.metadataCache.getFileCache(file).links[0].position.start.col is wrong on those two kinds of line.

Line [[ is at column The cache says
%% see [[target]] here (first line of a %% block comment) 7 5 (2 short, as if %% were not there)
- %% see [[target]] here (the same, inside a list item) 9 7
> ab cd [[target]] end (a callout’s unindented > line inside a list item) 8 9 (1 past)
> ab cd [[target]] end (the same line, indented under the item) 11 11 (correct)

Footnote references and embeds on those lines are off by the same amount (%% | ![[==mark==]], [[target]] reports the embed at column 3 and the link at 18; they are at 5 and 20). A link on any other line of the comment, or in an inline %%...%% comment, is renamed correctly.

So any feature that edits a note at the positions the cache reports (rename, and plugins that rewrite links) corrupts these lines. Writing a to-do or a note to self as %% TODO check [[note]] on the comment’s first line is a common way to use comments.

Environment

SYSTEM INFO:
	Obsidian version: 1.14.5
	Installer version: 1.14.4
	Operating system: Windows 11 Pro 10.0.26300
	Login status: not logged in
	Language: en
	Insider build toggle: off
	Live preview: on
	Base theme: adapt to system
	Community theme: none
	Snippets enabled: 0
	Restricted mode: on

RECOMMENDATIONS:
	none

Fresh vault, no community plugins, default theme. Also reproduced on the current Catalyst build.

Additional information

Re-paste “Show debug info” before posting.


Credit: found by @saberzero1 with the remark-obsidian parity harness; I re-checked it on 1.14.5 and the current Catalyst build.

2 Likes