yzhang-gh / vscode-markdown

Markdown All in One
https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one
MIT License
2.91k stars 322 forks source link

Markdown auto deletes Links to other markdown files in some cases #1418

Closed RaedAddala closed 5 months ago

RaedAddala commented 5 months ago

What's the problem

I have a table of contents that contains links to other markdown files as well as parts from the same markdown file. When the table of contents list started growing bit by bit, at some point Markdown started deleting all links to other markdown files from the table of contents.

This is weird, considering that if this is not a bug, it should either exhibit this behavior from the start.

I searched in the settings and couldn't find something relevant for this case.

What's the expected result

It should either work like this from the start or not at all.

How to reproduce

Here is the first example in which I noticed the bug: (the difference between the next two snapshots is that I added a link in the table of contents)

  1. Here is the list before: image

  2. Here is the list after: image

Note that the change was automatic and new. I worked with the extension for months and this is a first.

RaedAddala commented 5 months ago

Experimenting with it, I have found another example showcasing this problem.

Note that the only difference was removing an extension from a link:

  1. image

  2. image

RaedAddala commented 5 months ago

If this is not a bug but a normal extension behaviour, please make it so it functions this way from the start.

yzhang-gh commented 5 months ago

Thanks for the feedback. This is a feature that automatically detects and updates (optional) the TOC.

In your case, the list was not recognized as a TOC as it had "links", but as you added more TOC entries it was more likely to be a TOC, and then it was updated to the "real" TOC.

You can disable the automatic update of the TOC with the option markdown.extension.toc.updateOnSave but you will still see the small "Table of Contents (up to date)" hint. Or you can put a <!-- no toc --> comment right before your manually edited TOC.

RaedAddala commented 5 months ago

Thanks for your reply. It is clear to me now.

I suggest that you mention this part in the documentation or something like this. Just to avoid confusion in the future.