Skip to content

"Format Selection" can format the entire file #5169

@andrewkolos

Description

@andrewkolos

Repro

  1. Have your local flutter/flutter checkout at commit 4cb6d384926fe831697e1e6cc88a6deb8d602071 (near master at the time of writing)
  2. Open your flutter checkout in VSCode.
  3. Open packages/flutter_tools/lib/src/compile.dart
  4. Move your cursor to any line of code. I happened to choose this one.
  5. Open the command palette, run the Format Selection command.

Expected result. The selected line should be formatted like so

// Before
const List<String> kDartCompilerExperiments = <String>[
];

// After
const List<String> kDartCompilerExperiments = <String>[];

Observed result. The entire file gets formatted.

Diagnostics

Workspace Environment
Dart Code extension: 3.92.0
Flutter extension: 3.93.20240702 (activated)

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

Workspace type: Dart, Flutter (LSP)

Dart (3.5.0-321.0.dev): /Users/andrewkolos/Documents/GitHub/flutter/bin/cache/dart-sdk
Flutter (3.23.0-14.0.pre.112): /Users/andrewkolos/Documents/GitHub/flutter (macOS (darwin/macos))

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.5.0-321.0.dev (dev) (Mon Jul 1 13:02:44 2024 -0700) on "macos_arm64"
  • on macos / Version 14.5 (Build 23F79)
  • locale is en

Process info

Memory CPU Elapsed time Command line
26 MB 0.0% 41:15 dart devtools --machine --allow-embedding --dtd-uri ws:/Ob0NgnqHGxdJ9wu1
25 MB 0.0% 02:38:52 dart devtools --no-launch-browser
72 MB 0.0% 41:18 dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.92.0
605 MB 0.0% 41:15 dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.92.0
26 MB 0.0% 41:18 dart tooling-daemon --machine
27 MB 0.0% 41:16 dart tooling-daemon --machine
60 MB 0.0% 41:16 flutter_tools.snapshot daemon
Output from 'flutter doctor'

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

[!] Flutter (Channel [user-branch], 3.23.0-14.0.pre.112, on macOS 14.5 23F79 darwin-arm64, locale en)
    ! Flutter version 3.23.0-14.0.pre.112 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/setup.
    ! 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 7507cb44cb (2 hours ago), 2024-07-02 13:55:04 -0700
    • Engine revision 4427894144
    • Dart version 3.5.0 (build 3.5.0-321.0.dev)
    • DevTools version 2.37.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
    • ANDROID_SDK_ROOT = /Users/andrewkolos/Library/Android/sdk
    • Java binary at: /Users/andrewkolos/Applications/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 a package manager for iOS or macOS platform code.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/to/platform-plugins
      To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods

[✓] 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/Applications/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)

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

[✓] Connected device (3 available)
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 14.5 23F79 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 14.5 23F79 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome 126.0.6478.127

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

! Doctor found issues in 2 categories.

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 bugrelies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions