Skip to content

feat: multiline array support to the toml parser#176

Open
paval-shlyk wants to merge 1 commit into
saecki:mainfrom
paval-shlyk:fix-multiline-arrays
Open

feat: multiline array support to the toml parser#176
paval-shlyk wants to merge 1 commit into
saecki:mainfrom
paval-shlyk:fix-multiline-arrays

Conversation

@paval-shlyk

Copy link
Copy Markdown

Summary

This PR adds support for parsing multiline arrays in Cargo.toml, specifically addressing features lists that span multiple lines.

Relates to issue #77.

Changes

  • Updated lua/crates/toml.lua logic to detect multiline array starts and accumulate content until the closing bracket.
  • Refined regex patterns for single-line arrays to be stricter (removed ? optional check for closing bracket) to correctly fallback to the multiline parser when appropriate.
  • Added tests in test/multiline_spec.lua and test/repro_spec.lua covering:
    • Multiline features in dependency sections.
    • Multiline features in inline tables.
    • Trailing commas and whitespace handling.

Notes

  • I will be verifying this functionality through my own daily usage.
  • Additional testing from the community is welcome!
  • Note: This implementation was primarily "vibe coded" (as I don't use Lua on a primary basis). However, every change seems reasonable and the added tests pass.

@saecki

saecki commented Feb 10, 2026

Copy link
Copy Markdown
Owner

Hey, thanks for this PR! I'll try to take a closer look and try this out this weekend.

I've noticed a few things right away. I don't think the case where inline-array items come after the multiline features array is handled. The type declaration of TomlCrateFeat and TomlFeature doesn't seem to be updated. The feature editing logic in edit.lua probably needs updating. Same for the popup code, which will also need to check for line numbers.

Somewhat related, with TOML 1.1 support landing in cargo, there is now also the possibility of multiline inline-tables. I'm not sure if that changes anything about this PR, just came to mind :)

@paval-shlyk

Copy link
Copy Markdown
Author

I believed that everything would be much simpler)

Honestly, I didn't even know that multiline inline-tables had been added.

@saecki

saecki commented Feb 12, 2026

Copy link
Copy Markdown
Owner

I believed that everything would be much simpler)

🫂

Honestly, I didn't even know that multiline inline-tables had been added.

Even if this PR "only" adds support for multi-line features, that would still be an improvement worth while :)

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