Skip to content

Conversation

@matiascr
Copy link
Contributor

Addresses #5168

@matiascr matiascr changed the title Update with fixes to collapsing nested cases with lists Update with fixes to collapsing nested cases with list tails Nov 28, 2025
@matiascr matiascr force-pushed the fix-collapse_nested_cases_on_list_tails branch 2 times, most recently from b383eef to 5475223 Compare November 28, 2025 11:48
Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

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

Brilliant! Thank you! Few small Qs inline

} = matched_variable
{
// We need to un-nest the list when replacing the tail
let surrounding_brackets = Regex::new(r"(^\[|\]$)").expect("a valid regex");
Copy link
Member

Choose a reason for hiding this comment

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

Can we do this efficiently without regex? It's quite tricky to read this, and we tend not to use it.

If not then the regex will need to be cached in a static variable (currently it is recompiled every time) and it'll need a detailed comment explaining what this does. Thank you.

.to_string();

// We need to also remove the prefix when replacing the variable
// at the tail of the list
Copy link
Member

Choose a reason for hiding this comment

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

What does this mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps I could have been more clear... What I meant is that, rather than replacing the span of the variable, we need to use the span from the tail prefix to the end of the variable (prefix_and_variable_span)

Copy link
Member

Choose a reason for hiding this comment

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

I'm sorry, I don't understand. Could you add a detailed comment with examples please 🙏

@lpil lpil marked this pull request as draft December 4, 2025 14:03
@lpil
Copy link
Member

lpil commented Dec 4, 2025

When you are ready for a review please un-draft this PR and tag me for a review. Thank you!

@matiascr matiascr force-pushed the fix-collapse_nested_cases_on_list_tails branch from 5475223 to 764d3d3 Compare December 5, 2025 16:22
@matiascr matiascr force-pushed the fix-collapse_nested_cases_on_list_tails branch 2 times, most recently from 22bad62 to bdd982a Compare December 5, 2025 22:25
@matiascr matiascr force-pushed the fix-collapse_nested_cases_on_list_tails branch from bdd982a to 2332f28 Compare December 5, 2025 22:53
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.

2 participants