question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
klazukacommented, Sep 3, 2019

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:

  1. cmd+/ (insert line comment)
  2. run elm-format
  3. do cmd+/ again on that line to uncomment

The 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.

1reaction
klazukacommented, Aug 31, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found