Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Indentation-based approach to folding is not effective #568

Open
Labels
topic: infrastructureRelated to project infrastructure type: imperfectionPerceived defect in any part of project
@per1234

Description

Describe the problem

The IDE's code folding system assumes that code blocks will always be indented, and that indented text is always a code block.

🐛 This not a valid assumption. As a result, some code blocks are not foldable, some don't fold correctly, and some things fold that should not.

To reproduce

  1. Open a sketch that contains code with structure not reflected by indentation:

    /*
    this is not foldable
     this is foldable
    */
    /* this block is not foldable
    the IDE does not indent the contents of block comments
    */
    void setup() { // this block is not foldable
    #ifdef FOO // common code style is no indentation preprocessor blocks, since they are independent from the C++ code structure
     // this block is foldable
    #endif
    }
    void loop() { // This block folds incorrectly
     // only this line is folded when folding the `loop` block
    #ifdef FOO
     // this block is foldable
    #endif // this is treated as a block
     // this is not folded when folding the `loop` block
    bar: // this is treated as a block
     ; // this is not folded when folding the `loop` block
    }
  2. Hover the mouse pointer up and down through the left margin of the editor pane in the IDE. Noting the locations of the fold controls.

    • 🐛 Expected fold controls are missing at lines 1, 6, and 10.
    • 🐛 An unexpected fold control is present at lines 2 and 22.

    image

  3. Do a "Fold All". Note the results.

    • 🐛 Lines 7, 11-13, 18, 20, and 22 are not folded as expected

    image

Expected behavior

Folding occurs based on code structure, independent from indentation.

Arduino IDE version

Original report

2.0.0-beta.12-nightly.20211021

Last verified with

63e9dfd

Operating system

Windows

Operating system version

  • Windows 10
  • Windows 11

Additional context

Previously reported at arduino/arduino-pro-ide#13 and claimed to be fixed at that time, so perhaps a regression.


Folding is more reliable in the Arduino IDE 1.x:

image

image

Additional reports

Issue checklist

  • I searched for previous requests in the issue tracker
  • I verified the feature was still missing when using the latest nightly build
  • My request contains all necessary details

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: infrastructureRelated to project infrastructure type: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /