-
Notifications
You must be signed in to change notification settings - Fork 14
Improves inline comments #513
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
Changes from all commits
975afc9
5e07501
57ba715
df5db28
9852c2f
ef54a17
43f95c5
0ca2fd8
862526d
ce8f828
6b293a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ import { | |
| Group, | ||
| IndentationModifier, | ||
| INTERNAL_FORMAT_ERROR_MESSAGE, | ||
| isInlineComment, | ||
| shouldAddSpace, | ||
| } from './formattingHelpers'; | ||
|
|
||
|
|
@@ -122,7 +123,20 @@ function appendChunkText(state: State, chunk: Chunk) { | |
| } | ||
|
|
||
| function handleComments(state: State, chunk: Chunk) { | ||
| if (isInlineComment(chunk)) { | ||
| // Inline comment - append directly | ||
| state.formatted += ' '; | ||
| state.formatted += chunk.comment; | ||
| state.column += chunk.comment.length; | ||
| // Always include space after, even if the chunk has noSpace | ||
| if (chunk.type === 'REGULAR' && chunk.noSpace) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure how something can be a regular chunk if it is an inline comment? Why is it not a commentchunk?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No an inline comment is part of the regular chunk. It is only the comment which are completely on their own rows which are comment chunks.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now when I look at it, you might be able to do |
||
| state.formatted += ' '; | ||
| state.column++; | ||
| } | ||
| return; | ||
| } | ||
| if (chunk.comment) { | ||
| // For regular comments, we store them to append later | ||
| state.pendingComments.push(chunk.comment); | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are spaces added here if they are also added before and after the inlineComment in
formattingHelpersline 170?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are confusing the debug text with this one. In
formattingHelpersthe space are added for debug and to the group size, while it is added here to be included in the result.