nushell / nushell/nufmt

Formatting breaks with specific types of in template strings strings

Open
#220 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
230
Forks
40
Avg merge
15h 30m
Merged PRs (30d)
1

Description

Describe the bug

Formatting (parsing) breaks with some nested strings inside format strings.

Example:

> echo '$"("a:")"' | nufmt --stdin
$"(", a:")"

> echo '$"(http get "https://google.com")"' | nufmt --stdin
$"(http get ", https://google.com")"

When a similar sequence is present at any point in the script, none of it gets formatted

Environment

Please run show what operating system and version you're running and what version of nufmt you're running.

❯ $nu.os-info
❯ nufmt --version

╭────────────────┬───────────────╮
│ name           │ linux         │
│ arch           │ x86_64        │
│ family         │ unix          │
│ kernel_version │ 7.2.4-arch1-2 │
╰────────────────┴───────────────╯
nufmt 0.1.4
My Observations about the bug:

This appears to only happen when somewhere inside a template string, there is a string with a :, and something else preceding the colon. Doesn't happen when using nested 'single quote' string

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the examples with nufmt --stdin, especially template strings containing nested strings, a colon, and preceding text. Trace the formatter's template-string parsing from that CLI entry point. Done means both reported examples format correctly without breaking other template strings.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.