flutter / flutter/flutter-intellij

improve the behavior of format on poorly formed files

Open
#1,413 5 comments 1 reaction 0 assignees View on GitHub
dependency: dart sdk usability
Dominant language
Java
Stars
2k
Forks
356
Avg merge
1d 11h
Merged PRs (30d)
27

Description

When editing in build() methods, if the braces/parens aren’t balanced, hitting format will destroy the file. When you go to hit undo, IntelliJ asks if you want to undo through the format operation (which breaks your flow, to have to answer a dialog).

And for context, it's very easy when refactoring build methods - adding, removing, and reordering widgets - to get into a state where the parens are unbalanced.

![oct-23-2017 07-47-25](https://user-images.githubusercontent.com/1269969/31895616-80c9eda6-b7c6-11e7-950b-9792b06acc17.gif)

We should:
- verify that intellij is using the analysis server for formatting when the file is mis-formed
- follow up with dartfmt about being able to format bad files
- have intellij not ask about undoing through a format operation
- possibly, make the IntelliJ formatter (not dartfmt) format better when there are unbalanced (possibly related to https://youtrack.jetbrains.com/issue/WEB-28954)

/cc @alexander-doroshko @jwren

Contributor guide

Open the contributing guide

Research direction

No source file or test entry point is named. Start by reproducing formatting on a file with unbalanced braces or parentheses in IntelliJ, then investigate whether the analysis server or dartfmt handles the request and how the undo prompt is triggered. Done would require a decided scope and verified behavior for malformed files and undo handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.