-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect formatting with function chaining. #1135
Comments
This is working more or less as intended, but I agree the results don't look great. The formatter has heuristics around when to use "block-like" indentation for function expressions that appear as function arguments and when to use normal expression indentation. Those heuristics work pretty well in most cases, but not great in some like here. In particular, the main reason why the indentation is inconsistent in your example is because the first function expression uses Would you mind including this code as text in the issue and not a screenshot? If I get a chance to tweak these heuristics, I would like to use this as a regression test but don't want to have to retype it all by hand. |
I captured above screenshot as text in case it is useful: file
.readAsBytes()
.then(
(bytes) => ApiClient.instance.files.upload(
ownershipType: ownershipType,
file: MultipartFile.fromBytes(
bytes,
filename: filename,
),
),
)
.then(
(storageFile) {
_value = _value.add(id, FileUpload.fromStorageFile(storageFile));
notifyListeners();
},
).catchError(
(Object e) {
_value = _value.add(id, FileUpload.error(error: e, name: filename));
notifyListeners();
},
); |
It is, thank you! |
I ran the example through the forthcoming tall style and it produces: file
.readAsBytes()
.then(
(bytes) => ApiClient.instance.files.upload(
ownershipType: ownershipType,
file: MultipartFile.fromBytes(bytes, filename: filename),
),
)
.then((storageFile) {
_value = _value.add(id, FileUpload.fromStorageFile(storageFile));
notifyListeners();
})
.catchError((Object e) {
_value = _value.add(id, FileUpload.error(error: e, name: filename));
notifyListeners();
}); I believe that's exactly the requested output, so I think we're good. |
Formatted with dart format:
Seems, that correct formatting is:
Dart SDK version: 2.17.6 (stable) on "macos_arm64"
The text was updated successfully, but these errors were encountered: