obsidian-linter icon indicating copy to clipboard operation
obsidian-linter copied to clipboard

Bug: File Name Heading inserted numerous times

Open redactedscribe opened this issue 2 years ago • 8 comments
trafficstars

  • [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:

  1. Obsidian_2023-10-10_18-59-53
  2. 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

Obsidian_2023-10-10_19-05-05

Device

  • [x] Desktop
  • [ ] Mobile

Thanks!

redactedscribe avatar Oct 10 '23 16:10 redactedscribe

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.

pjkaufman avatar Oct 10 '23 16:10 pjkaufman

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.

pjkaufman avatar Oct 10 '23 16:10 pjkaufman

The result isn't desired so I'd argue that it's a bug to the user, although maybe correct in a technical sense.

redactedscribe avatar Oct 10 '23 16:10 redactedscribe

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?

pjkaufman avatar Oct 10 '23 18:10 pjkaufman

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.

redactedscribe avatar Oct 10 '23 18:10 redactedscribe

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.

redactedscribe avatar Oct 31 '23 22:10 redactedscribe

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 Screenshot 2023-12-06 at 08 02 10

timoz avatar Dec 05 '23 21:12 timoz

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.

pjkaufman avatar Dec 05 '23 22:12 pjkaufman