Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
7d85cebb
Commit
7d85cebb
authored
Oct 05, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preserve blank lines in // comments
R=gri DELTA=32 (13 added, 12 deleted, 7 changed) OCL=35317 CL=35332
parent
c5b056f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
src/pkg/go/doc/comment.go
src/pkg/go/doc/comment.go
+19
-18
No files found.
src/pkg/go/doc/comment.go
View file @
7d85cebb
...
...
@@ -76,24 +76,12 @@ func CommentText(comment *ast.CommentGroup) string {
l
=
l
[
m
[
1
]
:
len
(
l
)];
}
// throw away leading blank lines
if
w
==
0
&&
l
==
""
{
continue
;
}
cl
[
w
]
=
l
;
w
++
;
}
cl
=
cl
[
0
:
w
];
// throw away trailing blank lines
for
w
>
0
&&
cl
[
w
-
1
]
==
""
{
w
--
;
}
cl
=
cl
[
0
:
w
];
// add this comment to total list
// TODO: maybe separate with a single blank line
// if there is already a comment and len(cl) > 0?
// Add this comment to total list.
for
_
,
l
:=
range
cl
{
n
:=
len
(
lines
);
if
n
+
1
>=
cap
(
lines
)
{
...
...
@@ -108,10 +96,23 @@ func CommentText(comment *ast.CommentGroup) string {
}
}
// add final "" entry to get trailing newline.
// loop always leaves room for one more.
n
:=
len
(
lines
);
lines
=
lines
[
0
:
n
+
1
];
// Remove leading blank lines; convert runs of
// interior blank lines to a single blank line.
n
:=
0
;
for
_
,
line
:=
range
lines
{
if
line
!=
""
||
n
>
0
&&
lines
[
n
-
1
]
!=
""
{
lines
[
n
]
=
line
;
n
++
;
}
}
lines
=
lines
[
0
:
n
];
// Add final "" entry to get trailing newline from Join.
// The original loop always leaves room for one more.
if
n
>
0
&&
lines
[
n
-
1
]
!=
""
{
lines
=
lines
[
0
:
n
+
1
];
lines
[
n
]
=
""
;
}
return
strings
.
Join
(
lines
,
"
\n
"
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment