File tree 2 files changed +22
-0
lines changed
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -738,6 +738,7 @@ impl<'a> CommentRewrite<'a> {
738
738
if self . fmt . config . wrap_comments ( )
739
739
&& unicode_str_width ( line) > self . fmt . shape . width
740
740
&& !has_url ( line)
741
+ && !is_table_item ( line)
741
742
{
742
743
match rewrite_string ( line, & self . fmt , self . max_width ) {
743
744
Some ( ref s) => {
@@ -867,6 +868,12 @@ fn has_url(s: &str) -> bool {
867
868
s. contains ( "https://" ) || s. contains ( "http://" ) || s. contains ( "ftp://" ) || s. contains ( "file://" )
868
869
}
869
870
871
+ /// Returns true if the given string may be part of a Markdown talble.
872
+ fn is_table_item ( s : & str ) -> bool {
873
+ // This function may return false positive, but should get its job done in most cases.
874
+ s. trim_start ( ) . starts_with ( '|' )
875
+ }
876
+
870
877
/// Given the span, rewrite the missing comment inside it if available.
871
878
/// Note that the given span must only include comments (or leading/trailing whitespaces).
872
879
pub ( crate ) fn rewrite_missing_comment (
Original file line number Diff line number Diff line change
1
+ // rustfmt-wrap_comments: true
2
+
3
+ /// Table that is > 80 symbols:
4
+ ///
5
+ /// | table | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
6
+ /// |-------|-----------------------------------------------------------------------------|
7
+ /// | val | x |
8
+ pub struct Item ;
9
+
10
+ /// Table that is > 80 symbols:
11
+ ///
12
+ /// | table | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
13
+ /// |-------|-----------------------------------------------------------------------------
14
+ /// | val | x
15
+ pub struct Item ;
You can’t perform that action at this time.
0 commit comments