Skip to content

getFoldWidgetRange(row) returns undefined for YAML when called on rows not at the start of a fold region #5888

@stultvox

Description

@stultvox

Describe the bug

The getFoldWidgetRange(row) function behaves inconsistently between YAML and XML. For YAML, it only returns a valid fold range if called on the first line of the fold region. For XML, the function correctly returns the entire fold region even when called on lines within the fold.

Expected Behavior

Calling getFoldWidgetRange(row) on any line within a fold region should return the full fold region, regardless of whether the line is the first, middle, or last line of that region. Behavior should be consistent across file types, including YAML and XML.

Current Behavior

In YAML code, getFoldWidgetRange(row) returns undefined when called on a row that is not the first line of the fold region. This inconsistent behavior does not occur in XML files, where the same function correctly identifies the full fold range for any line within the folded structure.

Reproduction Steps

  1. Create a YAML code snippet with nested elements, such as:
catalog:
  things:
    element:
      - name: stuff
        type: junk
        version: '0.0'
          textstuff: There's some stuff about this junk
          textstuff: There's some more stuff about this junk
      - name: extrastuff
        type: extrajunk
  1. Call getFoldWidgetRange(3) → returns expected fold region.
  2. Call getFoldWidgetRange(4) → still returns expected fold region.
  3. Call getFoldWidgetRange(5) → returns undefined.
  4. Repeat the same test with the equivalent XML structure:
<catalog>
  <things>
    <element name="stuff" type="junk" version="0.0">
      <textstuff>There's some stuff about this junk</textstuff>
      <textstuff>There's some more stuff about this junk</textstuff>
    </element>
  </things>
</catalog>

Observe that getFoldWidgetRange(row) works correctly for any line within the fold region in XML.

Possible Solution

No response

Additional Information/Context

using files from package 17.10.25 src-min-noconflict
Same behavior when I used the same source as the demo: v1.42.0
Able to reproduce in Windows/Chrome and Linux/Safari

Ace Version / Browser / OS / Keyboard layout

using files from package 17.10.25 src-min-noconflict / Chrome / Windows 11

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions