Skip to content

fix: comments don't eat newlines#1186

Merged
a-h merged 1 commit intomainfrom
fix-single-line-comments
Jun 10, 2025
Merged

fix: comments don't eat newlines#1186
a-h merged 1 commit intomainfrom
fix-single-line-comments

Conversation

@joerdav
Copy link
Copy Markdown
Collaborator

@joerdav joerdav commented Jun 10, 2025

Fixes #1182

@joerdav joerdav force-pushed the fix-single-line-comments branch from eb83a71 to feebc2a Compare June 10, 2025 10:18
return
}
// Move past the end element.
_, _, _ = goSingleLineCommentEnd.Parse(pi)
Copy link
Copy Markdown
Collaborator Author

@joerdav joerdav Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything in this file apart from these 2 deletions are just formatting nits.

@joerdav joerdav requested review from a-h and Copilot and removed request for Copilot June 10, 2025 10:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that comment parsers no longer consume trailing newlines and updates tests to expect explicit newline whitespace nodes.

  • Added explicit newline whitespace expectations in template parser tests
  • Introduced a new if‐expression test covering else‐branch comments and indentation
  • Refactored the Go comment parser to stop eating newlines and cleaned up var/type declarations

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
parser/v2/templateparser_test.go Added Whitespace{Value: "\n"} to the comment’s child nodes
parser/v2/ifexpressionparser_test.go Added a test case for else with a comment and indentation
parser/v2/gocommentparser.go Removed end‐of‐line consumption from single‐line comment parser and grouped var/type declarations
Comments suppressed due to low confidence (1)

parser/v2/gocommentparser.go:7

  • This var block has manually aligned assignments that won’t be preserved by gofmt. Consider running gofmt (or go fmt) to normalize formatting and remove manual alignment.
var (

@a-h
Copy link
Copy Markdown
Owner

a-h commented Jun 10, 2025

Legend. Thanks.

@a-h a-h merged commit c9bd939 into main Jun 10, 2025
9 checks passed
@SteveRuble
Copy link
Copy Markdown

Wow, speedy! Thanks!.

@joerdav
Copy link
Copy Markdown
Collaborator Author

joerdav commented Jun 10, 2025

Pleasure, not often you get to fix a bug just by deleting code :D

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

If branch containing only a comment causes a parsing error

4 participants