Skip to content

Don't append a new-line after Indent.#1214

Open
hildebrandmw wants to merge 2 commits into
mainfrom
mhildebr/indent
Open

Don't append a new-line after Indent.#1214
hildebrandmw wants to merge 2 commits into
mainfrom
mhildebr/indent

Conversation

@hildebrandmw

Copy link
Copy Markdown
Contributor

Currently, Indent is always appending a newline to its last printed line. However, this can make formatting weird when using Indent to render nested blocks. This PR removes the trailing newline.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts diskann-benchmark-runner’s Indent formatter so it no longer appends a trailing newline, improving composition when rendering nested/multi-part formatted blocks.

Changes:

  • Updated Indent’s Display implementation to avoid emitting a newline after the final line.
  • Updated Indent examples/tests to match the new no-trailing-newline behavior.
  • Adjusted CLI output in app.rs to explicitly print newlines where Indent previously provided them implicitly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
diskann-benchmark-runner/src/utils/fmt.rs Changes Indent formatting behavior and updates related tests/example.
diskann-benchmark-runner/src/app.rs Updates output formatting to account for Indent no longer ending with a newline.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 196 to +206
/// Indents each line of a string by a fixed number of spaces.
///
/// Each line is prefixed with `spaces` spaces and terminated with a newline.
///
/// # Examples
///
/// ```
/// use diskann_benchmark_runner::utils::fmt::Indent;
///
/// let indented = Indent::new("hello\nworld", 4).to_string();
/// assert_eq!(indented, " hello\n world\n");
/// assert_eq!(indented, " hello\n world");
Comment on lines 529 to 533
#[test]
fn test_indent_multi_line() {
let s = Indent::new("hello\nworld\nfoo", 2).to_string();
assert_eq!(s, " hello\n world\n foo\n");
assert_eq!(s, " hello\n world\n foo");
}
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.82%. Comparing base (5b11031) to head (3dfcd20).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1214      +/-   ##
==========================================
- Coverage   89.82%   89.82%   -0.01%     
==========================================
  Files         489      489              
  Lines       93575    93579       +4     
==========================================
+ Hits        84051    84054       +3     
- Misses       9524     9525       +1     
Flag Coverage Δ
miri 89.82% <100.00%> (-0.01%) ⬇️
unittests 89.48% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
diskann-benchmark-runner/src/app.rs 83.97% <100.00%> (ø)
diskann-benchmark-runner/src/utils/fmt.rs 98.40% <100.00%> (+0.02%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants