Conversation
Reviewer's GuideThis pull request enhances the list renumbering logic to correctly reset numbering after paragraphs with lower indentation and adds a corresponding integration test to verify the behavior. Sequence diagram for list renumbering reset after paragraphsequenceDiagram
participant User
participant renumber_lists
participant is_plain_paragraph_line
User->>renumber_lists: Provide lines with lists and paragraphs
renumber_lists->>is_plain_paragraph_line: Check if line is a plain paragraph
is_plain_paragraph_line-->>renumber_lists: Return true/false
renumber_lists-->>User: Output lines with renumbered lists (reset after paragraph)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughThis update enhances the list renumbering logic by adding detection of plain paragraph lines and tracking blank lines to reset list counters appropriately. It introduces helper functions for managing counters by indentation and adds comprehensive tests to ensure numbering restarts correctly after paragraphs interrupt lists, including complex nested content. Changes
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.rsInstructions used from: Sources:
⚙️ CodeRabbit Configuration File 🔇 Additional comments (1)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
src/lists.rs(3 hunks)tests/data/renumber_paragraph_restart_expected.txt(1 hunks)tests/data/renumber_paragraph_restart_input.txt(1 hunks)tests/integration.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- AGENTS.md
⚙️ CodeRabbit Configuration File
🧬 Code Graph Analysis (2)
src/lists.rs (1)
src/wrap.rs (1)
is_fence(107-107)
tests/integration.rs (1)
src/lists.rs (1)
renumber_lists(37-96)
🔇 Additional comments (6)
tests/data/renumber_paragraph_restart_expected.txt (1)
1-27: Test data correctly demonstrates list restart behaviour.The expected output properly shows list numbering restarting from 1 after the plain paragraph at line 9, which validates the core functionality described in the PR objectives.
tests/data/renumber_paragraph_restart_input.txt (1)
1-27: Input test data properly sets up the renumbering scenario.The sequential numbering 1-7 provides a clear baseline to test against, with the plain paragraph at line 9 serving as the trigger point for list restart.
src/lists.rs (3)
41-41: Initialisation of prev_blank is correct.Starting with
truemakes sense as we want to treat the beginning of input as if there was a preceding blank line.
47-47: prev_blank state tracking is correctly implemented.The boolean is properly updated after processing fence lines, code blocks, numbered list lines, and other lines to maintain accurate blank line tracking.
Also applies to: 53-53, 71-71, 92-92
29-34: Add documentation for the new helper function.The
is_plain_paragraph_linefunction lacks Rustdoc comments. Document its purpose and behaviour according to the coding guidelines.+/// Determines whether a line represents a plain paragraph by checking if it starts with an +/// alphanumeric character after trimming leading whitespace. +/// +/// # Arguments +/// * `line` - The line to examine +/// +/// # Returns +/// `true` if the line starts with an alphanumeric character, `false` otherwise fn is_plain_paragraph_line(line: &str) -> bool {Likely an incorrect or invalid review comment.
tests/integration.rs (1)
1013-1024: Integration test properly validates the new functionality.The test correctly loads external test data, processes it through
renumber_lists, and validates the expected restart behaviour. The implementation follows established patterns in the codebase.
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/lists.rs:41` </location>
<code_context>
let mut out = Vec::with_capacity(lines.len());
let mut counters: Vec<(usize, usize)> = Vec::new();
let mut in_code = false;
+ let mut prev_blank = true;
for line in lines {
</code_context>
<issue_to_address>
Initializing prev_blank to true may cause the first line to be treated as following a blank line.
Consider initializing prev_blank based on whether the first line is blank to avoid unintended behavior at the start of the document.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
let mut in_code = false;
let mut prev_blank = true;
for line in lines {
=======
let mut in_code = false;
let mut prev_blank = lines.first().map(|l| l.trim().is_empty()).unwrap_or(true);
for line in lines {
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `src/lists.rs:81` </location>
<code_context>
.map_or_else(|| line.len(), |(i, _)| i);
let indent_str = &line[..indent_end];
let indent = indent_len(indent_str);
+ if prev_blank
+ && counters
+ .last()
</code_context>
<issue_to_address>
Consider extracting the paragraph-restart logic into its own function to simplify the main loop and improve code clarity.
Consider extracting the paragraph-restart logic into a dedicated function to reduce main loop complexity and improve readability. For example:
```rust
fn handle_paragraph_restart(
line: &str,
prev_blank: bool,
counters: &mut Vec<(usize, usize)>
) {
let indent_end = line
.char_indices()
.find(|&(_, c)| !c.is_whitespace())
.map_or_else(|| line.len(), |(i, _)| i);
let indent = indent_len(&line[..indent_end]);
if prev_blank
&& counters
.last()
.is_some_and(|(d, _)| indent <= *d && is_plain_paragraph_line(line))
{
while counters.last().is_some_and(|(d, _)| *d >= indent) {
counters.pop();
}
}
}
```
Then, in the main loop, replace the nested logic with a single call:
```rust
handle_paragraph_restart(line, prev_blank, &mut counters);
drop_deeper(indent, &mut counters);
out.push(line.clone());
prev_blank = line.trim().is_empty();
```
This keeps the main loop focused and makes the paragraph-restart logic easier to test and maintain.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| let mut in_code = false; | ||
| let mut prev_blank = true; | ||
|
|
||
| for line in lines { |
There was a problem hiding this comment.
suggestion: Initializing prev_blank to true may cause the first line to be treated as following a blank line.
Consider initializing prev_blank based on whether the first line is blank to avoid unintended behavior at the start of the document.
| let mut in_code = false; | |
| let mut prev_blank = true; | |
| for line in lines { | |
| let mut in_code = false; | |
| let mut prev_blank = lines.first().map(|l| l.trim().is_empty()).unwrap_or(true); | |
| for line in lines { |
| .map_or_else(|| line.len(), |(i, _)| i); | ||
| let indent_str = &line[..indent_end]; | ||
| let indent = indent_len(indent_str); | ||
| if prev_blank |
There was a problem hiding this comment.
issue (complexity): Consider extracting the paragraph-restart logic into its own function to simplify the main loop and improve code clarity.
Consider extracting the paragraph-restart logic into a dedicated function to reduce main loop complexity and improve readability. For example:
fn handle_paragraph_restart(
line: &str,
prev_blank: bool,
counters: &mut Vec<(usize, usize)>
) {
let indent_end = line
.char_indices()
.find(|&(_, c)| !c.is_whitespace())
.map_or_else(|| line.len(), |(i, _)| i);
let indent = indent_len(&line[..indent_end]);
if prev_blank
&& counters
.last()
.is_some_and(|(d, _)| indent <= *d && is_plain_paragraph_line(line))
{
while counters.last().is_some_and(|(d, _)| *d >= indent) {
counters.pop();
}
}
}Then, in the main loop, replace the nested logic with a single call:
handle_paragraph_restart(line, prev_blank, &mut counters);
drop_deeper(indent, &mut counters);
out.push(line.clone());
prev_blank = line.trim().is_empty();This keeps the main loop focused and makes the paragraph-restart logic easier to test and maintain.
There was a problem hiding this comment.
Actionable comments posted: 3
♻️ Duplicate comments (3)
src/lists.rs (3)
36-41: Address the past review feedback correctly.This implementation addresses the past review suggestion to extract the helper function, but the
#[doc(hidden)]attribute contradicts the requirement for public API documentation.Apply this fix:
-#[doc(hidden)] +/// Removes all counters with indentation greater than or equal to the specified level. +/// +/// This function is used to reset list numbering when encountering paragraph content +/// that interrupts nested lists at a given indentation level. +/// +/// # Arguments +/// * `counters` - Mutable reference to the counter stack +/// * `indent` - The indentation level threshold for removal pub fn pop_counters_upto(counters: &mut Vec<(usize, usize)>, indent: usize) {
48-48: Fix the problematic initialisation.The
prev_blank = trueinitialisation creates incorrect behaviour for the first line, as noted in past review feedback.Apply this correction:
- let mut prev_blank = true; + let mut prev_blank = lines.first().map_or(true, |line| line.trim().is_empty());
88-94: Extract the complex conditional logic into a dedicated function.This nested conditional violates the complexity guidelines and duplicates the suggestion from past review feedback.
Extract into a helper function above the main loop:
/// Handles paragraph restart logic by popping counters when appropriate conditions are met. fn handle_paragraph_restart( line: &str, prev_blank: bool, counters: &mut Vec<(usize, usize)>, indent: usize, ) { if prev_blank && counters .last() .is_some_and(|(d, _)| indent <= *d && is_plain_paragraph_line(line)) { pop_counters_upto(counters, indent); } }Then replace the nested logic:
- if prev_blank - && counters - .last() - .is_some_and(|(d, _)| indent <= *d && is_plain_paragraph_line(line)) - { - pop_counters_upto(&mut counters, indent); - } + handle_paragraph_restart(line, prev_blank, &mut counters, indent);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
src/lists.rs(3 hunks)tests/lists.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- AGENTS.md
⚙️ CodeRabbit Configuration File
🧬 Code Graph Analysis (1)
src/lists.rs (1)
src/wrap.rs (1)
is_fence(107-107)
🔇 Additional comments (4)
src/lists.rs (4)
54-60: Ensure consistent prev_blank tracking.The
prev_blankassignment logic appears correct for fence and code block handling, maintaining proper state tracking.
78-78: Correct prev_blank assignment for numbered lists.The assignment correctly sets
prev_blank = falseafter processing numbered list items, maintaining proper state tracking.
97-97: Verify prev_blank logic for general lines.The assignment correctly determines if the current line is blank for the next iteration's logic.
29-34: Document the helper function purpose.The function lacks documentation explaining its purpose and usage, violating the Rustdoc requirement for public APIs.
Add proper documentation:
+/// Determines if a line represents a plain paragraph (starts with alphanumeric after whitespace). +/// +/// Returns `true` if the line's first non-whitespace character is alphanumeric, +/// indicating it's likely the start of a paragraph rather than a special markdown element. fn is_plain_paragraph_line(line: &str) -> bool {Likely an incorrect or invalid review comment.
| macro_rules! lines_vec { | ||
| ($($line:expr),* $(,)?) => { | ||
| vec![$($line.to_string()),*] | ||
| }; | ||
| } |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Extract the macro into a test utility module.
The lines_vec! macro is useful but should be moved to a shared test utilities module to promote reusability across test files.
Apply this refactor:
-macro_rules! lines_vec {
- ($($line:expr),* $(,)?) => {
- vec![$($line.to_string()),*]
- };
-}Create tests/common/mod.rs:
#[macro_export]
macro_rules! lines_vec {
($($line:expr),* $(,)?) => {
vec![$($line.to_string()),*]
};
}Then import it:
+mod common;
use mdtablefix::{lists::pop_counters_upto, renumber_lists};
+use common::lines_vec;🤖 Prompt for AI Agents
In tests/lists.rs around lines 3 to 7, the lines_vec! macro should be moved to a
shared test utility module for reuse. Create a new file tests/common/mod.rs and
define the lines_vec! macro there with #[macro_export]. Then, in tests/lists.rs
and other test files, import the macro by adding `#[macro_use] extern crate
common;` or the appropriate import statement to use lines_vec! from the common
module.
| #[test] | ||
| fn pop_counters_removes_deeper_levels() { | ||
| let mut counters = vec![(0usize, 1usize), (4, 2), (8, 3)]; | ||
| pop_counters_upto(&mut counters, 4); | ||
| assert_eq!(counters, vec![(0, 1)]); | ||
| } | ||
|
|
||
| #[test] | ||
| fn pop_counters_no_change_when_indent_deeper() { | ||
| let mut counters = vec![(0usize, 1usize), (4, 2)]; | ||
| pop_counters_upto(&mut counters, 6); | ||
| assert_eq!(counters, vec![(0, 1), (4, 2)]); | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Add edge case tests for pop_counters_upto.
The unit tests cover basic scenarios but miss important edge cases that could reveal bugs.
Add these additional test cases:
#[test]
fn pop_counters_empty_vec() {
let mut counters = vec![];
pop_counters_upto(&mut counters, 0);
assert_eq!(counters, vec![]);
}
#[test]
fn pop_counters_exact_match() {
let mut counters = vec![(0usize, 1usize), (4, 2)];
pop_counters_upto(&mut counters, 4);
assert_eq!(counters, vec![(0, 1)]);
}🤖 Prompt for AI Agents
In tests/lists.rs around lines 9 to 21, add two new unit tests for
pop_counters_upto to cover edge cases: one test with an empty counters vector to
ensure no changes occur, and another test where the indent exactly matches an
element in counters to verify correct removal behavior. Implement these tests by
initializing the counters vector accordingly, calling pop_counters_upto with the
specified indent, and asserting the expected resulting vector.
| #[test] | ||
| fn restart_after_lower_paragraph() { | ||
| let input = lines_vec!("1. One", "", "Paragraph", "3. Next"); | ||
| let expected = lines_vec!("1. One", "", "Paragraph", "1. Next"); | ||
| assert_eq!(renumber_lists(&input), expected); | ||
| } | ||
|
|
||
| #[test] | ||
| fn no_restart_without_blank() { | ||
| let input = lines_vec!("1. One", "Paragraph", "3. Next"); | ||
| let expected = lines_vec!("1. One", "Paragraph", "2. Next"); | ||
| assert_eq!(renumber_lists(&input), expected); | ||
| } | ||
|
|
||
| #[test] | ||
| fn no_restart_for_indented_paragraph() { | ||
| let input = lines_vec!("1. One", "", " Indented", "3. Next"); | ||
| let expected = lines_vec!("1. One", "", " Indented", "2. Next"); | ||
| assert_eq!(renumber_lists(&input), expected); | ||
| } | ||
|
|
||
| #[test] | ||
| fn no_restart_for_non_plain_line() { | ||
| let input = lines_vec!("1. One", "", "# Heading", "3. Next"); | ||
| let expected = lines_vec!("1. One", "", "# Heading", "2. Next"); | ||
| assert_eq!(renumber_lists(&input), expected); | ||
| } | ||
|
|
||
| #[test] | ||
| fn restart_after_nested_paragraph() { | ||
| let input = lines_vec!("1. One", " 1. Sub", "", "Paragraph", "3. Next"); | ||
| let expected = lines_vec!("1. One", " 1. Sub", "", "Paragraph", "1. Next"); | ||
| assert_eq!(renumber_lists(&input), expected); | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Use rstest parameterised tests to reduce duplication.
The integration tests follow a repetitive pattern that violates DRY principles. Replace with parameterised tests as mandated by the coding guidelines.
Apply this refactor:
use rstest::rstest;
#[rstest]
#[case(
lines_vec!("1. One", "", "Paragraph", "3. Next"),
lines_vec!("1. One", "", "Paragraph", "1. Next"),
"restart_after_lower_paragraph"
)]
#[case(
lines_vec!("1. One", "Paragraph", "3. Next"),
lines_vec!("1. One", "Paragraph", "2. Next"),
"no_restart_without_blank"
)]
#[case(
lines_vec!("1. One", "", " Indented", "3. Next"),
lines_vec!("1. One", "", " Indented", "2. Next"),
"no_restart_for_indented_paragraph"
)]
#[case(
lines_vec!("1. One", "", "# Heading", "3. Next"),
lines_vec!("1. One", "", "# Heading", "2. Next"),
"no_restart_for_non_plain_line"
)]
#[case(
lines_vec!("1. One", " 1. Sub", "", "Paragraph", "3. Next"),
lines_vec!("1. One", " 1. Sub", "", "Paragraph", "1. Next"),
"restart_after_nested_paragraph"
)]
fn test_renumber_lists_scenarios(
#[case] input: Vec<String>,
#[case] expected: Vec<String>,
#[case] _description: &str,
) {
assert_eq!(renumber_lists(&input), expected);
}🤖 Prompt for AI Agents
In tests/lists.rs from lines 23 to 56, the test functions for renumber_lists are
repetitive and violate DRY principles. Refactor by replacing the multiple
individual #[test] functions with a single parameterized test using the rstest
crate. Define a #[rstest] function with multiple #[case] attributes, each
containing the input vector, expected output vector, and a description string.
This will consolidate all test cases into one function that asserts equality for
each case, reducing duplication and improving maintainability.
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
src/lists.rs(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- AGENTS.md
⚙️ CodeRabbit Configuration File
🧬 Code Graph Analysis (1)
src/lists.rs (1)
src/wrap.rs (1)
is_fence(107-107)
🔇 Additional comments (2)
src/lists.rs (2)
64-64: Excellent implementation of paragraph restart tracking.The
prev_blankinitialization correctly addresses the past review comment about first line handling. The implementation properly handles empty input.
104-107: Well-integrated paragraph restart functionality.The integration of
handle_paragraph_restartinto the main loop is correctly positioned and maintains proper state tracking. The consistentprev_blankupdates across all code paths ensure reliable behaviour.
| fn handle_paragraph_restart(line: &str, prev_blank: bool, counters: &mut Vec<(usize, usize)>) { | ||
| let indent_end = line | ||
| .char_indices() | ||
| .find(|&(_, c)| !c.is_whitespace()) | ||
| .map_or_else(|| line.len(), |(i, _)| i); | ||
| let indent = indent_len(&line[..indent_end]); | ||
|
|
||
| if prev_blank | ||
| && counters | ||
| .last() | ||
| .is_some_and(|(d, _)| indent <= *d && is_plain_paragraph_line(line)) | ||
| { | ||
| pop_counters_upto(counters, indent); | ||
| } | ||
| } |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Add documentation for the extracted logic.
Excellent work extracting the complex paragraph restart logic as suggested in past reviews. Add documentation to explain the function's purpose.
+/// Handles resetting list counters when a paragraph line follows a blank line
+/// at or before the indentation level of the last counter.
fn handle_paragraph_restart(line: &str, prev_blank: bool, counters: &mut Vec<(usize, usize)>) {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| fn handle_paragraph_restart(line: &str, prev_blank: bool, counters: &mut Vec<(usize, usize)>) { | |
| let indent_end = line | |
| .char_indices() | |
| .find(|&(_, c)| !c.is_whitespace()) | |
| .map_or_else(|| line.len(), |(i, _)| i); | |
| let indent = indent_len(&line[..indent_end]); | |
| if prev_blank | |
| && counters | |
| .last() | |
| .is_some_and(|(d, _)| indent <= *d && is_plain_paragraph_line(line)) | |
| { | |
| pop_counters_upto(counters, indent); | |
| } | |
| } | |
| /// Handles resetting list counters when a paragraph line follows a blank line | |
| /// at or before the indentation level of the last counter. | |
| fn handle_paragraph_restart(line: &str, prev_blank: bool, counters: &mut Vec<(usize, usize)>) { | |
| let indent_end = line | |
| .char_indices() | |
| .find(|&(_, c)| !c.is_whitespace()) | |
| .map_or_else(|| line.len(), |(i, _)| i); | |
| let indent = indent_len(&line[..indent_end]); | |
| if prev_blank | |
| && counters | |
| .last() | |
| .is_some_and(|(d, _)| indent <= *d && is_plain_paragraph_line(line)) | |
| { | |
| pop_counters_upto(counters, indent); | |
| } | |
| } |
🤖 Prompt for AI Agents
In src/lists.rs around lines 43 to 57, the function handle_paragraph_restart
lacks documentation explaining its purpose. Add a clear doc comment above the
function describing that it handles restarting paragraphs based on indentation
and blank line context, detailing the role of its parameters and the effect on
the counters vector.
| fn is_plain_paragraph_line(line: &str) -> bool { | ||
| line.trim_start() | ||
| .chars() | ||
| .next() | ||
| .is_some_and(char::is_alphanumeric) | ||
| } |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Add documentation for the helper function.
Add a doc comment explaining the function's purpose and behaviour.
+/// Determines whether a line represents a plain paragraph by checking if it starts
+/// with an alphanumeric character after any leading whitespace.
fn is_plain_paragraph_line(line: &str) -> bool {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| fn is_plain_paragraph_line(line: &str) -> bool { | |
| line.trim_start() | |
| .chars() | |
| .next() | |
| .is_some_and(char::is_alphanumeric) | |
| } | |
| /// Determines whether a line represents a plain paragraph by checking if it starts | |
| /// with an alphanumeric character after any leading whitespace. | |
| fn is_plain_paragraph_line(line: &str) -> bool { | |
| line.trim_start() | |
| .chars() | |
| .next() | |
| .is_some_and(char::is_alphanumeric) | |
| } |
🤖 Prompt for AI Agents
In src/lists.rs around lines 29 to 34, the helper function
is_plain_paragraph_line lacks documentation. Add a doc comment above the
function that clearly explains its purpose, which is to check if a line starts
with an alphanumeric character after trimming leading whitespace, indicating it
is a plain paragraph line.
| #[doc(hidden)] | ||
| pub fn pop_counters_upto(counters: &mut Vec<(usize, usize)>, indent: usize) { | ||
| while counters.last().is_some_and(|(d, _)| *d >= indent) { | ||
| counters.pop(); | ||
| } | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Fix visibility and documentation issues.
Address the following issues with this function:
- Remove
#[doc(hidden)]and add proper documentation since this is a public function - The function uses
>=comparison whiledrop_deeperuses>- ensure this difference is intentional - Consider making this function private if it's only used internally
-#[doc(hidden)]
-pub fn pop_counters_upto(counters: &mut Vec<(usize, usize)>, indent: usize) {
+/// Removes all counters from the stack whose indentation is greater than or equal
+/// to the specified indentation level.
+fn pop_counters_upto(counters: &mut Vec<(usize, usize)>, indent: usize) {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| #[doc(hidden)] | |
| pub fn pop_counters_upto(counters: &mut Vec<(usize, usize)>, indent: usize) { | |
| while counters.last().is_some_and(|(d, _)| *d >= indent) { | |
| counters.pop(); | |
| } | |
| } | |
| /// Removes all counters from the stack whose indentation is greater than or equal | |
| /// to the specified indentation level. | |
| fn pop_counters_upto(counters: &mut Vec<(usize, usize)>, indent: usize) { | |
| while counters.last().is_some_and(|(d, _)| *d >= indent) { | |
| counters.pop(); | |
| } | |
| } |
🤖 Prompt for AI Agents
In src/lists.rs around lines 36 to 41, remove the #[doc(hidden)] attribute and
add clear, proper documentation explaining the purpose and behavior of the
pop_counters_upto function. Review the comparison operator in the while loop to
confirm if using >= is intentional compared to drop_deeper's >; if not, align
them accordingly. Finally, if this function is only used internally within the
module, change its visibility from public to private by removing the pub
keyword.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai resume |
✅ Actions performedReviews resumed. |
Summary
renumber_listsTesting
make lintmake testhttps://chatgpt.com/codex/tasks/task_e_68783b2c18b883228ee08234b4788f4f
Summary by Sourcery
Improve list renumbering to correctly restart numbering after paragraphs with lower indentation and add corresponding integration test.
Enhancements:
Tests: