Remove leading whitespace when doing line-comment
See original GitHub issue@justgook pointed out that the current behavior results in strange indentation when combined with how elm-format handles line comments. The IntelliJ default is to have the line comment start on the first column (far left edge). But elm-format doesn’t like that.
Here’s how the line commenter checks the preference in com.intellij.codeInsight.generation.CommentByLineCommentHandler
:
CommonCodeStyleSettings languageSettings = CodeStyle.getLanguageSettings(psiFile, lineStartLanguage);
block.commentWithIndent = !languageSettings.LINE_COMMENT_AT_FIRST_COLUMN;
We should set LINE_COMMENT_AT_FIRST_COLUMN
to false for all Elm code.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Remove extra leading spaces in single-line comments in Eclipse
My projects in Eclipse using spaces to format code, not tabs. When commenting lines with single-line comment (pressing Ctrl + / ), leading...
Read more >How do I trim leading and trailing whitespace from each line of ...
Show activity on this post. Finally, to only remove leading/trailing whitespace (e.g. unwanted indentation), you can use the appropriate trim-leading or trim- ...
Read more >Removal of leading spaces from comments
I have some comments in an Objective-C file which I formatted with some leading spaces on some of the lines for readability (these...
Read more >Remove Comments - LeetCode
Given a C++ program, remove comments from it. ... The string "//" denotes a line comment, which represents that it and the rest...
Read more >spaced-line-comment - ESLint - Pluggable JavaScript Linter
(removed) This rule was removed in ESLint v1.0 and replaced by the ... require or disallow a whitespace immediately after the initial //...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I didn’t know about
IndentedCommenter
. That sounds like a good place to start.My main requirement is that any comment inserted by IntelliJ round-trips nicely through elm-format. And it should look “reasonable” at each step.
So if I do:
cmd+/
(insert line comment)cmd+/
again on that line to uncommentThe code after each step should be formatted “reasonably”. It doesn’t mean that it has to be perfect, but it shouldn’t be terribly wrong either. And the final output after step 3 should (ideally) match the initial state before step 1 was performed. Obviously it can’t be totally reversible because
elm-format
tends to do crazy things with comments, but for most situations it should meet expectations.So I would pick whichever option achieves the above goals and has the simplest implementation.
Go for it. I don’t know offhand if there are any other issues that are better suited. This one shouldn’t be too hard, and I can help you if you have any questions.