Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1741)

Unified Diff: mojom/mojom_parser/formatter/printer.go

Issue 1822233002: Handle the case where a single-line comment is less than 3 characters long. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/tools/bindings/mojom_tool/bin/mac64/mojom.sha1 ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojom/mojom_parser/formatter/printer.go
diff --git a/mojom/mojom_parser/formatter/printer.go b/mojom/mojom_parser/formatter/printer.go
index 821defa5602180b0a02ea896ba1b065f949929b4..6de06c3c2e80b2fc60eee83fb434b0f5f2de99f5 100644
--- a/mojom/mojom_parser/formatter/printer.go
+++ b/mojom/mojom_parser/formatter/printer.go
@@ -664,8 +664,7 @@ func (p *printer) writeSingleLineComment(comment lexer.Token) {
// We expect that the first 2 characters are // followed by a space or tab.
// If the third character is not a space or tab, we insert a space.
- space := commentText[2]
- if space != ' ' && space != '\t' {
+ if len(commentText) > 2 && commentText[2] != ' ' && commentText[2] != '\t' {
commentText = "// " + commentText[2:]
}
p.write(commentText)
« no previous file with comments | « mojo/public/tools/bindings/mojom_tool/bin/mac64/mojom.sha1 ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698