Skip to content

Collapsing ruby functions with ensure blocks don't fully collapse #7

Open

Description

@bradgessler

When I collapse a function in a Ruby function in Zed, it shows ensure, rescue, etc. blocks.

Here's an example:

Zed.Bug.mp4

You can recreate with a function like this:

def foo
  puts "hi"
rescue 
  puts "Rescued!"
ensure
  puts "bye ya'll"
end

I don't know if its a bug, bit it is surprising when I first collapse the function.

Activity

  1. andyw8 commented on Mar 24, 2025

    @andyw8
    Contributor

    If Zed implemented language server support for textDocument/foldingRange then it could use Ruby LSP's implementation which collapses the whole def.

    Doesn't seem on the radar though: zed-industries/zed#26916

  2. andyw8 commented on Apr 4, 2025

    @andyw8
    Contributor
  3. added theissue type on Apr 24, 2025
  4. joeldrapper commented on Apr 28, 2025

    @joeldrapper
    Contributor

    I looked into whether this could be implemented directly in the Zed extension and it looks like it’s not possible. Zed folds based on the indentation level.

    We can control which syntax queries trigger indents and outdents, which is why when you type ensure it is automatically outdented. But there’s no way to write queries for folding ranges as far as I can tell.

  5. andyw8 commented on Feb 6, 2026

    @andyw8
    Contributor

    I haven't tried it yet, but foldingRange support was just merged: zed-industries/zed#48611

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstreamZed issue (not extension)

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions