Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: File Name Heading inserted numerous times #911

Open
2 of 3 tasks
redactedscribe opened this issue Oct 10, 2023 · 8 comments
Open
2 of 3 tasks

Bug: File Name Heading inserted numerous times #911

redactedscribe opened this issue Oct 10, 2023 · 8 comments
Labels
bug Something isn't working rule conflict 2 rules are conflicting with each other which is causing the reported behavior

Comments

@redactedscribe
Copy link

  • 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

  • Desktop
  • Mobile

Thanks!

@redactedscribe redactedscribe added the bug Something isn't working label Oct 10, 2023
@pjkaufman
Copy link
Collaborator

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
Copy link
Collaborator

Here is the issue mentioning the recursion issue: #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.

@redactedscribe
Copy link
Author

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

@pjkaufman
Copy link
Collaborator

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?

@redactedscribe
Copy link
Author

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
Copy link
Author

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.

@timoz
Copy link

timoz commented Dec 5, 2023

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

@pjkaufman
Copy link
Collaborator

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 pjkaufman added the rule conflict 2 rules are conflicting with each other which is causing the reported behavior label Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rule conflict 2 rules are conflicting with each other which is causing the reported behavior
Projects
None yet
Development

No branches or pull requests

3 participants