Skip to content

Only try to fixup broken AST issue 220 - #221

Open
JustLinuxUser wants to merge 2 commits into
nushell:mainfrom
JustLinuxUser:main
Open

Only try to fixup broken AST issue 220#221
JustLinuxUser wants to merge 2 commits into
nushell:mainfrom
JustLinuxUser:main

Conversation

@JustLinuxUser

Copy link
Copy Markdown

Description of changes

There are "detectors of broken code", that were used to fixup trivial issues. An issue with that is that they are not perfect, and are far more likely to be broken in an unexpected way. So this change only runs them, when the AST is broken.

Although this PR doesn't address the root cause of #220, it is the correct thing to do in the long run anyway.

Added a test, that would break because detect_missing_record_comma_spans would detect an error where one didn't exist. Fixed by not running it on good AST.

Relevant Issues

#220

@JustLinuxUser

Copy link
Copy Markdown
Author

Note, for some god forsaken reason, github is not visualizing the whitespace properly on this pr, so if it seems a little strange, do a git diff/show manually

@JustLinuxUser

Copy link
Copy Markdown
Author

Ok, I fixed all the tests, (previously I only ran tests/run_ground_trought_tests.nu, and apparently it didn't run all the tests? weird... Anyway, at this point this solution seems less valid, because the approach is less general, so it's your call weather it makes sense or no.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Missing-comma repair can still run against valid AST regions through other repair detectors.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Restricts missing-record-comma detection to malformed ASTs and adds regression coverage for issue #220.

Changes:

  • Gates comma-repair detection on parse errors or garbage nodes.
  • Adds nested-interpolation formatting and idempotency fixtures.
File summaries
File Description
src/formatting/mod.rs Gates missing-comma detection.
tests/ground_truth.rs Registers regression tests.
tests/fixtures/input/nested_interpolation_issue220.nu Adds regression input.
tests/fixtures/expected/nested_interpolation_issue220.nu Defines expected formatting.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/formatting/mod.rs
Comment on lines +291 to +293
// Only try to detect fixable errors if the AST is broken
if has_parsing_malformed_spans || has_garbage {
malformed_spans.extend(detect_missing_record_comma_spans(&source_text));
Comment thread tests/ground_truth.rs
(
"nested_interpolation_issue220",
ground_truth_nested_interpolation_issue220,
idempotencynested_interpolation_issue220
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