-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
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
- 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
- Call getFoldWidgetRange(3) → returns expected fold region.
- Call getFoldWidgetRange(4) → still returns expected fold region.
- Call getFoldWidgetRange(5) → returns undefined.
- 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