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

Following ij_formatter_{off,on}_tag pair #1163

Closed
njokipal opened this issue Jun 9, 2021 · 2 comments · Fixed by #1895
Closed

Following ij_formatter_{off,on}_tag pair #1163

njokipal opened this issue Jun 9, 2021 · 2 comments · Fixed by #1895
Milestone

Comments

@njokipal
Copy link

njokipal commented Jun 9, 2021

At the moment ktlint has the per-line // ktlint-disable marker comments for disabling rules, which is nice.
Currently, I write my code with IntelliJ IDEA, that offers the notion of formatter off and formatter on tag pair, which default to //@formatter:off and //@formatter:on comment pairs. These values may also be configured in an EditorConfig file using ij_formatter_off_tag and ij_formatter_on_tag keys.

In my code, I have some very long lines with some look-up data, like lists/maps of hundreds of static values, which I deem aren't really that important to be visible at once, for them to follow the max_line_length value set using EditorConfig value. I'll wrap those blobs of code with the formatter off/on pair, and IDEA won't auto-format them for me.

For ktlint, I have to insert additional /* ktlint-disable max-line-length */ and /* ktlint-enable max-line-length */ comment pair around the the no-format block, which seems redundant.

Could there be a possibility to obey the no-formatting tags or define a set of no-format boundaries keys setting for using non-ktlint-disable?

Expected Behavior

ktlint would obey existing/provide additional no-format boundary comments

Current Behavior

Additional // ktlint-disable max-line-length,... needs to be added for each row inside already in the no-format block for the IDE

Additional information

  • Current version of ktlint: 0.40.0
@paul-dingemans
Copy link
Collaborator

This should be marked as an enhancement. The request seems very valid to me although I do not use those markers myself.

In case .editorconfig property ij_formatter_tags_enabled is true than handle tag ij_formatter_off_tag same as ktlint-disable and ij_formatter_on_tag same as ktlint-enable. This only requires a change in the SupressedRegionLocator.

However this should only be done after the Indent rule has been refactored and no longer works on the entire file (see #631).

paul-dingemans added a commit that referenced this issue Mar 28, 2023
@paul-dingemans paul-dingemans added this to the 0.49.0 milestone Mar 28, 2023
@paul-dingemans
Copy link
Collaborator

Duplicates #670

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants