Skip to content

[Bug] "Inverse fold behavior" triggers unexpectedly when creating a new code block #159

@connot-fail

Description

@connot-fail

Describe the bug
When the "Inverse fold behavior" option is enabled in the Folding Settings, creating a new code block by typing ```` (backticks) causes the newly created block to immediately fold. This behavior is unexpected and disruptive to the workflow.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Settings > Code Styler > Folding Settings.
  2. Enable the "Inverse fold behavior" option.
  3. In a note, start a new code block by typing ````.
  4. Observe the new code block is created and instantly folded.

Expected behavior
The new code block should be created in an unfolded state, allowing the user to continue typing without interruption. The "Inverse fold behavior" option should only affect the initial state of existing code blocks when a note is opened, or should be explicitly triggered, not activate upon creation.

Actual behavior
Upon creation, the new code block is automatically folded, and the text cursor is moved outside the code block. This forces the user to manually unfold the code block to begin writing code, disrupting the natural flow of typing.

Screenshots
(If applicable, add screenshots or a short screen recording to help explain your problem.)

Environment (please complete the following information):

  • OS: [e.g., Windows 11, macOS 14.5]
  • Obsidian Version: [e.g., 1.6.7]
  • Code Styler Plugin Version: [e.g., 1.2.0]
  • Theme: [e.g., Default, Minimal]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions