Skip to content

Commit

Permalink
bugfix: doc parser panic when empty line length less than min margin
Browse files Browse the repository at this point in the history
  • Loading branch information
He1pa committed Aug 9, 2023
1 parent 115b71b commit 5cfb20f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions kclvm/sema/src/resolver/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ fn clean_doc(doc: &mut String) {
.unwrap_or(0);

lines[1..].iter_mut().for_each(|line| {
*line = if line.len() > 0 {
&line[margin..]
*line = if line.trim().len() > 0 {
if let Some(sub) = line.get(margin..) {
sub
} else {
line.trim()
}
} else {
line
line.trim()
}; // remove command indentation
});

Expand Down Expand Up @@ -354,7 +358,7 @@ de",
A Server-level attribute.
The labels of the long-running service.
See also: kusion_models/core/v1/metadata.k.
Examples
----------------------
myCustomApp = AppConfiguration {
Expand Down
2 changes: 1 addition & 1 deletion kclvm/sema/src/resolver/test_data/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
A Server-level attribute.
The labels of the long-running service.
See also: kusion_models/core/v1/metadata.k.

Examples
----------------------
myCustomApp = AppConfiguration {
Expand Down

0 comments on commit 5cfb20f

Please sign in to comment.