phcode-dev / phoenix

Phoenix is a modern open-source Code Editor for the web, built for the browser.
https://phcode.io
GNU Affero General Public License v3.0
1.79k stars 124 forks source link

Code Folding Issue with Beautify on Save Feature #1845

Open devvaannsh opened 2 months ago

devvaannsh commented 2 months ago

Describe the bug

When using "Beautify Code after Save" feature :- When I manually collapse sections of my code (clicking the collapse arrow to fold sections of code) and then continue writing new code elsewhere, the collapsed sections automatically expand after saving, which is unexpected behavior. Sometimes, the code expands but the collapse button remains in the collapsed state, meaning the visual icon does not update to reflect the actual state of the code section. This issue disrupts the workflow, as I have to manually collapse the code sections again after each save.

Attaching a GIF for reference :- ScreenRecording2024-09-12203741-ezgif com-video-to-gif-converter

As shown in the attached GIF, I folded a section of code, wrote some new code, and upon saving (with the Beautify on Save feature enabled), the folded code automatically expands. I then folded another part of the code, wrote more, and saved again. This time, the code expanded, but the collapse icon did not update to reflect the change.

Reproduction

  1. Write some code and collapse a section using the collapse button.
  2. Write additional code elsewhere in the file.
  3. Save the file to trigger the beautification feature.
  4. Observe that the collapsed code expands automatically, but the collapse button sometimes remains in the collapsed state.

Expected behavior

Collapsed code sections should remain collapsed after saving. The collapse button should accurately reflect the state of the code (collapsed/expanded).

OS, Browser and Phoenix versions

Phoenix version :- Release 3.9 build 3.9.4-20562 build timestamp: 2024-09-09T07:23:11.000Z

OS version :- Windows 11 Issue also persists across browsers (tested in Chrome & Firefox)

logs or debug stack trace if any

No response

Additional context

No response