Skip to content
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

Support for File-Specific Code Formatting Settings #232954

Closed
Okladnoj opened this issue Nov 4, 2024 · 6 comments
Closed

Support for File-Specific Code Formatting Settings #232954

Okladnoj opened this issue Nov 4, 2024 · 6 comments
Assignees
Labels
config VS Code configuration, set up issues *duplicate Issue identified as a duplicate of another issue(s)

Comments

@Okladnoj
Copy link

Okladnoj commented Nov 4, 2024

I would like to request support for file-specific code formatting settings in VS Code. Specifically, the ability to configure editor.rulers, editor.formatOnSave, and other formatting options based on file patterns or specific file extensions, such as **/*_model.dart.

This feature would be especially useful for Dart and other languages where generated code, like constructors from packages like Freezed, becomes less readable with a standard line length of 80 characters. Being able to specify a longer line length (e.g., 200 characters) for these specific files would improve code readability without affecting the rest of the project.

Example of Desired Configuration:

"[dart]": {
  "editor.rulers": [80]
},
"**/*_model.dart": {
  "editor.rulers": [200]
}

Code Example Highlighting the Issue:

@immutable
@Freezed(makeCollectionsUnmodifiable: false)
class TransactionsRequestModel with _$TransactionsRequestModel {
  const TransactionsRequestModel._();

  @HiveType(typeId: HiveManager.idTransactionsRequestModel)
  const factory TransactionsRequestModel({
    @HiveField(0) @JsonKey(name: 'type') @Default(TransactionType.all) @TransactionTypeConverter() TransactionType type,
    @HiveField(1) @JsonKey(name: 'sort_by') @Default(SortFactorType.displayMostRecent) @SortFactorTypeConverter() SortFactorType sortFactor,
    @HiveField(2) @JsonKey(name: 'date_from') @DateConverter() DateTime? dateFrom,
    @HiveField(3) @JsonKey(name: 'date_to') @DateConverter() DateTime? dateTo,
    @HiveField(4) @JsonKey(name: 'search') @Default('') String search,
    @HiveField(5) @JsonKey(name: 'page') @Default(1) int page,
    @HiveField(6) @JsonKey(name: 'tags') @Default([]) @TagConverter() List<TagModel> tags,
    @HiveField(7) @JsonKey(name: 'category') int? categoryId,
  }) = _TransactionsRequestModel;

  factory TransactionsRequestModel.fromJson(Map<String, dynamic> json) =>
      _$TransactionsRequestModelFromJson(json);

  StatisticRequestModel get toStatistic {
    return StatisticRequestModel(
      type: type,
      dateTo: dateTo,
      dateFrom: dateFrom,
      search: search,
      tags: tags,
    );
  }
}

As shown above, setting the line length to 80 characters makes these constructors difficult to read and manage. A more flexible approach for file-specific formatting settings would greatly improve developer productivity and code clarity.

@sandy081
Copy link
Member

/duplicate

@vs-code-engineering vs-code-engineering bot added the *duplicate Issue identified as a duplicate of another issue(s) label Nov 11, 2024
Copy link

Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for similar existing issues. See also our issue reporting guidelines.

Happy Coding!

@vs-code-engineering vs-code-engineering bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 11, 2024
@Okladnoj
Copy link
Author

@sandy081 @jrieken

Please wait... how is this a "duplicate"?

I searched for discussions on a similar topic but couldn’t find anything. Could you please provide a link to the earlier, active issue that this has been marked as a duplicate of? I believe this is a very important feature that will make the IT world more productive, and I would like to track the progress in this direction.

Best regards,
Dmitriy

@sandy081 sandy081 added the config VS Code configuration, set up issues label Nov 15, 2024
@sandy081
Copy link
Member

#35350

@Okladnoj
Copy link
Author

Thank you for the link!

@Xevion
Copy link

Xevion commented Nov 17, 2024

#35350

It should be required that you provide a link to the duplicate issue when closing someone's issue that they clearly spent far more time writing than you did writing your reply. No one deserves a 1-word rejection.

@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Dec 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
config VS Code configuration, set up issues *duplicate Issue identified as a duplicate of another issue(s)
Projects
None yet
Development

No branches or pull requests

4 participants