Skip to content

Collapsed code blocks are not restored properly #29846

@PerfunctoryOrator

Description

@PerfunctoryOrator

Upon opening Zed, I discovered that the code was folded at unexpected locations, such as within words, letters, and other characters.

There seems to be at least 3 related issues:

First Issue

Image Description: A screenshot showing the problematic folded code.

While the issue is not as pronounced in the provided screenshot, it occasionally occurs even when the application is open. For instance, suppose the code in lines 280 to 310 is folded, and I am currently working in lines 120 to 130. After some time, when I scroll down to view the folded code in lines 280 to 310, it appears significantly altered.

Second Issue

The folds do not persist anytime I install a new Zed update.
I recently found out that the issue is not only limited to installing a Zed update, but also occurs when I open Zed, then close (quit) it without editing any files (the folds are still visible), and then open it again. All the folds disappear.

Third Issue

The code folds are preserved between restarts only for the file which was focused when closing Zed.
All other files of the same project which were open in other tabs in the background while closing Zed did not preserve their folds.

In addition, I would like to suggest some modifications to enhance the visual representation of folded code. Consider this screenshot:

Image Description: A screenshot demonstrating the improved representation of folded code.

Observe that the folded line is highlighted with a subtle blue tint. Furthermore, the midline horizontal ellipsis (⋯) has a distinct background colour and is immediately preceded by the closing brackets.

With the exception of Python files (which do not utilise curly brackets), I believe this approach is the most effective method for representing folded code.

Zed Version and System Specs

Zed: v0.184.9 (Zed)
OS: macOS 15.4.1
Memory: 8 GiB
Architecture: aarch64

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:code foldingarea:editorFeedback for code editing, formatting, editor iterations, etcarea:serializationRestoration of the editor state after a restartnever staleto keep the stalebot awaystate:needs triagetriage is not complete: no `area:*` label, or no `priority:*`/`frequency:*` for Bugs/Crashes

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions