diff options
author | Tim Schumacher <timschumi@gmx.de> | 2023-03-01 17:24:50 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-03-13 15:16:20 +0000 |
commit | ae51c1821c0d32ba40b866d8e5561f6de3359b17 (patch) | |
tree | 6bd2d0964841bf5bd56797ad4a887e8e4e3ac63c /Userland/Libraries/LibLine | |
parent | 26516ee1601b0662bb1753f834a179bf1a20082d (diff) | |
download | serenity-ae51c1821c0d32ba40b866d8e5561f6de3359b17.zip |
Everywhere: Remove unintentional partial stream reads and writes
Diffstat (limited to 'Userland/Libraries/LibLine')
-rw-r--r-- | Userland/Libraries/LibLine/XtermSuggestionDisplay.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/Userland/Libraries/LibLine/XtermSuggestionDisplay.cpp b/Userland/Libraries/LibLine/XtermSuggestionDisplay.cpp index 98833292f0..fbb8a552ff 100644 --- a/Userland/Libraries/LibLine/XtermSuggestionDisplay.cpp +++ b/Userland/Libraries/LibLine/XtermSuggestionDisplay.cpp @@ -51,8 +51,7 @@ ErrorOr<void> XtermSuggestionDisplay::display(SuggestionManager const& manager) // the suggestion list to fit in the prompt line. auto start = max_line_count - m_prompt_lines_at_suggestion_initiation; for (size_t i = start; i < max_line_count; ++i) - // FIXME: This should write the entire span. - TRY(stderr_stream->write_some("\n"sv.bytes())); + TRY(stderr_stream->write_until_depleted("\n"sv.bytes())); lines_used += max_line_count; longest_suggestion_length = 0; } @@ -100,8 +99,7 @@ ErrorOr<void> XtermSuggestionDisplay::display(SuggestionManager const& manager) if (next_column > m_num_columns) { auto lines = (suggestion.text_view.length() + m_num_columns - 1) / m_num_columns; lines_used += lines; - // FIXME: This should write the entire span. - TRY(stderr_stream->write_some("\n"sv.bytes())); + TRY(stderr_stream->write_until_depleted("\n"sv.bytes())); num_printed = 0; } @@ -117,13 +115,11 @@ ErrorOr<void> XtermSuggestionDisplay::display(SuggestionManager const& manager) if (spans_entire_line) { num_printed += m_num_columns; - // FIXME: This should write the entire span. - TRY(stderr_stream->write_some(suggestion.text_string.bytes())); - TRY(stderr_stream->write_some(suggestion.display_trivia_string.bytes())); + TRY(stderr_stream->write_until_depleted(suggestion.text_string.bytes())); + TRY(stderr_stream->write_until_depleted(suggestion.display_trivia_string.bytes())); } else { auto field = DeprecatedString::formatted("{: <{}} {}", suggestion.text_string, longest_suggestion_byte_length_without_trivia, suggestion.display_trivia_string); - // FIXME: This should write the entire span. - TRY(stderr_stream->write_some(DeprecatedString::formatted("{: <{}}", field, longest_suggestion_byte_length + 2).bytes())); + TRY(stderr_stream->write_until_depleted(DeprecatedString::formatted("{: <{}}", field, longest_suggestion_byte_length + 2).bytes())); num_printed += longest_suggestion_length + 2; } @@ -154,8 +150,7 @@ ErrorOr<void> XtermSuggestionDisplay::display(SuggestionManager const& manager) TRY(VT::move_absolute(m_origin_row + lines_used, m_num_columns - string.length() - 1, *stderr_stream)); TRY(VT::apply_style({ Style::Background(Style::XtermColor::Green) }, *stderr_stream)); - // FIXME: This should write the entire span. - TRY(stderr_stream->write_some(string.bytes())); + TRY(stderr_stream->write_until_depleted(string.bytes())); TRY(VT::apply_style(Style::reset_style(), *stderr_stream)); } |