Skip to content

Code folding not working for functions where parameters span multiple lines #4931

Closed

Description

@andrewkolos

Sorry for the vague title. This is on pre-release (more info in the diagnostic info later).

Describe the bug
In a specific file I'm working in, code folding seems to not work for any for loops. Interestingly, upon reloading the window, it works very briefly before breaking.

To Reproduce
Steps to reproduce the behavior:

  1. Checkout this specific commit on my fork of flutter/flutter: https://github.com/andrewkolos/flutter/tree/a0c24d34c0895910b32e4b71cb6aff38a8803c5d
  2. Navigate to packages/flutter_tools/lib/src/asset.dart.
  3. Navigate to any for loop and observe that it cannot be folded. There's no folding chevron on the left, and the Fold All VS command will not fold any for loop.

Expected behavior
Folding works for all blocks.

Screenshots
image

Workspace Environment
Dart Code extension: 3.81.20231227
Flutter extension: 3.81.20231227 (activated)

App: Visual Studio Code
App Host: desktop
Version: mac 1.85.1

Workspace type: Dart, Flutter (LSP)

Dart (3.3.0-276.0.dev): /Users/andrewkolos/Documents/GitHub/flutter/bin/cache/dart-sdk
Flutter (3.18.0-19.0.pre.59): /Users/andrewkolos/Documents/GitHub/flutter (iPhone 15 Pro Max (ios/ios))

Output from 'dart info'

/Users/andrewkolos/Documents/GitHub/flutter/bin/cache/dart-sdk/bin/dart info

If providing this information as part of reporting a bug, please review the information
below to ensure it only contains things you're comfortable posting publicly.

General info

  • Dart 3.3.0-276.0.dev (dev) (Tue Jan 2 12:03:57 2024 -0800) on "macos_arm64"
  • on macos / Version 14.2.1 (Build 23C71)
  • locale is en

Process info

Memory CPU Elapsed time Command line
8 MB 0.0% 01-21:33:55 dart devtools --machine --allow-embedding
48 MB 0.0% 28:14 dart devtools --machine --allow-embedding
15 MB 0.0% 01-21:33:55 dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.81.20231227
736 MB 0.0% 28:14 dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.81.20231227
80 MB 0.3% 28:14 flutter_tools.snapshot daemon
Output from 'flutter doctor'

/Users/andrewkolos/Documents/GitHub/flutter/bin/flutter doctor -v

[!] Flutter (Channel [user-branch], 3.18.0-19.0.pre.59, on macOS 14.2.1 23C71 darwin-arm64, locale en)
    ! Flutter version 3.18.0-19.0.pre.59 on channel [user-branch] at /Users/andrewkolos/Documents/GitHub/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
    ! The flutter binary is not on your path. Consider adding /Users/andrewkolos/Documents/GitHub/flutter/bin to your path.
    ! The dart binary is not on your path. Consider adding /Users/andrewkolos/Documents/GitHub/flutter/bin to your path.
    ! Upstream repository https://github.com/andrewkolos/flutter.git is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to https://github.com/andrewkolos/flutter.git to dismiss this error.
    • Framework revision a0c24d34c0 (2 days ago), 2024-01-09 09:42:05 -0800
    • Engine revision f539acfb8c
    • Dart version 3.3.0 (build 3.3.0-276.0.dev)
    • DevTools version 2.31.0-dev.0
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/andrewkolos/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Users/andrewkolos/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/231.9392.1.2311.11076708/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A507
    ! CocoaPods 1.12.0 out of date (1.13.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods for instructions.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1)
    • Android Studio at /Users/andrewkolos/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/231.9392.1.2311.11076708/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[!] Android Studio (version unknown)
    • Android Studio at /Users/andrewkolos/Desktop/Android Studio Preview.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to determine Android Studio version.
    • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.85.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.81.20231227

[✓] Connected device (3 available)
    • iPhone 15 Pro Max (mobile) • 1F50AF7D-FCB5-4839-81DE-954252A38693 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-0 (simulator)
    • macOS (desktop)            • macos                                • darwin-arm64   • macOS 14.2.1 23C71 darwin-arm64
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 120.0.6099.216

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 3 categories.

Activity

  1. andrewkolos commented on Jan 11, 2024

    @andrewkolos
    Author

    This appears to be not necessarily a for loop issue, as I am also unable to fold the _createAssetManifestBinary in the file as well.

  2. DanTup commented on Jan 11, 2024

    @DanTup
    Member

    I think this is the same as #4780? I have that assigned to try and look at this month, but I haven't gotten to it yet.

  3. DanTup commented on Jan 11, 2024

    @DanTup
    Member

    _createAssetManifestBinary

    This might be different though.. I suspect it's because we produce two folding regions (one for the args, one for the body). I thought we'd fixed that somehow in the past but I don't recall how. I'll keep this issue open to track that just in case.

  4. changed the title [-]Code folding not working for some `for` loops[/-] [+]Code folding not working for functions where parameters span multiple lines[/+] on Jan 11, 2024
  5. added this to the v3.82.0 milestone on Jan 11, 2024
  6. added
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    in editorRelates to code editing or language features
    on Jan 11, 2024
  7. andrewkolos commented on Jan 11, 2024

    @andrewkolos
    Author

    I think this is the same as #4780? I have that assigned to try and look at this month, but I haven't gotten to it yet.

    Yeah, I just realized—my bad! When I opened this, my memory thought #4780 was resolved in pre-release already.

    _createAssetManifestBinary

    This might be different though.. I suspect it's because we produce two folding regions (one for the args, one for the body). I thought we'd fixed that somehow in the past but I don't recall how. I'll keep this issue open to track that just in case.

    Yeah, if you play around with the file, you might find a couple more interesting folding failures. For example, the folding region for a documentation block (///) eats up the beginning of a class definition, and a bunch of class members are mysteriously lumped into a folding region with a method signature.

    2024-01-11_09-19-01.mp4

    Feel free to close this as redundant with #4780. I can always post more repros there instead.

  8. DanTup commented on Jan 22, 2024

    @DanTup
    Member

    I'll keep this one open for the weird folding overlaps as the other one was for for loops, thanks for the extra examples!

  9. modified the milestones: v3.82.0, v3.84.0 on Jan 29, 2024
  10. DanTup commented on Feb 6, 2024

    @DanTup
    Member

    I think this one has already been fixed - on the current version I can fold both the args or the function noted above:

    image

    If you still see issues with things that don't fold (that aren't covered by #4780 and #4723 which I'm just looking at), please let me know (and provide a sample). Thanks!

  11. DanTup commented on Feb 6, 2024

    @DanTup
    Member

    (btw, I don't seem to be able to play the video above to see what other examples it had.. it plays like the first half second then stops, and if I try to skip, it just jumps back to the start)

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

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions