obsidian-linter
obsidian-linter copied to clipboard
Bug: File Name Heading inserted numerous times
- [x] I have verified that I am on the latest version of the Linter
Describe the Bug
With the below three options enabled, the file name is inserted as a header recursively:
- File Name Heading: Inserts the file name as a H1 heading if no H1 heading exists.
- Header Increment: Heading levels should only increment by one level at a time
- Header Increment: Start Header Increment at Heading Level 2
How to Reproduce
Steps to reproduce the behavior:
- Lint a file multiple times.
Expected Behavior
A single file name heading to be inserted / not allow the user to end up with this set of simultaneous options. I only use the latter two options, but I just happened to notice the bug when testing.
Screenshots
Device
- [x] Desktop
- [ ] Mobile
Thanks!
Hey @redactedscribe . This is not really a bug. A H2 is not a file heading. H1 is a file heading. There is an issue somewhere that requests that a warning be shown for this scenario here.
Here is the issue mentioning the recursion issue: https://github.com/platers/obsidian-linter/issues/856.
There are several rules that are not compatible together. However the rules themselves do not know what other rules are enabled in general. Thus the Linter would need a way to know that you have incompatible options selected.
The result isn't desired so I'd argue that it's a bug to the user, although maybe correct in a technical sense.
Given what has been stated, what is the proposed remedy here? If we do conaider this a bug, does showing a warning when both are enabled constitute a valid fix or should it disable the rule since they are not compatible?
It only appears to occur when both of Header Increment's options are enabled. It could get complex to manage checking of different combinations of rules, so perhaps something simpler: A warning symbol present on options which are known to have incompatible rules. Any rules listed could potentially be clicked and the plugin scroll to the position of said rule. This way the user will at least have a heads-up on what not to do, or how to solve some strange behaviour. If on the other hand you want to implement something more comprehensive, then disabling of rules when conflicts are found, with some confirmation beforehand similar to conflicting hotkeys, isn't a bad choice.
Hey @redactedscribe . This is not really a bug. A H2 is not a file heading. H1 is a file heading. There is an issue somewhere that requests that a warning be shown for this scenario here.
It could be argued however that someone may want the title to be duplicated as the first H2 heading. When a user configures Linter with the options as shown in the screenshot, instead of showing a warning, the title could just be inserted at the top as ## <title> without incrementing the rest of the headings.
I have experienced this problem too. Must've got carried away with the options. I managed to accidentally create a bunch headers for one file starting with H2 before I realised it was Linter-related
This is definitely a pain point I do not have time to work on right now. However I am open to PRs to fix this while I am working on other features/bugs.