Skip to content

Commit

Permalink
Fixing formatting of long unsplittable words. (#5906)
Browse files Browse the repository at this point in the history
  • Loading branch information
orizi committed Jun 26, 2024
1 parent a90d32f commit 86baee8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion crates/cairo-lang-formatter/src/formatter_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,9 @@ fn format_leading_comment(content: &str, cur_indent: usize, max_line_width: usiz
};
last_line_broken = false;
for word in orig_comment_line.content.split(' ') {
if current_line.content.len() + word.len() <= max_comment_width {
if current_line.content.is_empty()
|| current_line.content.len() + word.len() <= max_comment_width
{
current_line.content.push_str(word);
current_line.content.push(' ');
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,5 @@ fn function_for_a_comment() {
let x = 1;
}





// leading words long_single_word_that_should_not_be_broken_not_creating_additional_empty_lines_padding_padding_padding_padding
fn function_for_a_comment() {}
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,6 @@ fn function_for_a_comment() {
let x = 1;
}

// leading words
// long_single_word_that_should_not_be_broken_not_creating_additional_empty_lines_padding_padding_padding_padding
fn function_for_a_comment() {}

0 comments on commit 86baee8

Please sign in to comment.