Skip to content

Reformat indented strings to simple strings when appropriate#348

Merged
infinisil merged 1 commit intoNixOS:masterfrom
dyegoaurelio:reformat-idented-strings
Oct 28, 2025
Merged

Reformat indented strings to simple strings when appropriate#348
infinisil merged 1 commit intoNixOS:masterfrom
dyegoaurelio:reformat-idented-strings

Conversation

@dyegoaurelio
Copy link
Copy Markdown
Contributor

Converts indented strings to simple strings when they contain no newlines, quotes, or backslashes. For example: ''hello'' becomes "hello" and ''path/to/file'' becomes "path/to/file".

Also handles escape sequence conversion (''$ -> $ and ''' -> '') and updates standard.md to document this behavior.

closes #274

@github-actions
Copy link
Copy Markdown

github-actions bot commented Oct 23, 2025

Nixpkgs diff

@dyegoaurelio dyegoaurelio force-pushed the reformat-idented-strings branch 2 times, most recently from 15149da to f2216b0 Compare October 23, 2025 19:19
@MattSturgeon
Copy link
Copy Markdown
Contributor

There's some related discussion in:

Which were all closed because we're hesitant to do syntax transformations.

This does fall under that umbrella, but personally I'm not opposed to simple, well defined, limited scope cases like this one.

@jfly jfly moved this to Approved in Nix formatting Oct 28, 2025
Copy link
Copy Markdown
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

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

Looking good! Let's also add a test case for this string (as an indented version without the " and \) just to be sure we don't miss anything

@jfly jfly moved this from Approved to Todo in Nix formatting Oct 28, 2025
@nixos-discourse
Copy link
Copy Markdown

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/formatting-team-meeting-2025-10-14/71449/1

@dyegoaurelio dyegoaurelio force-pushed the reformat-idented-strings branch from f2216b0 to 8c2924b Compare October 28, 2025 20:31
Converts indented strings to simple strings when they contain no newlines,
quotes, or backslashes. For example: ''hello'' becomes "hello" and
''path/to/file'' becomes "path/to/file".

Also handles escape sequence conversion (''$ -> \$ and ''' -> '') and
updates standard.md to document this behavior.
@dyegoaurelio dyegoaurelio force-pushed the reformat-idented-strings branch from 8c2924b to 52dbbd3 Compare October 28, 2025 20:47
Copy link
Copy Markdown
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

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

Looking good, thanks!

@infinisil infinisil enabled auto-merge October 28, 2025 20:51
@infinisil infinisil merged commit f7d6074 into NixOS:master Oct 28, 2025
2 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Nix formatting Oct 28, 2025
@dyegoaurelio dyegoaurelio deleted the reformat-idented-strings branch October 29, 2025 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Single-line multiline strings not containing " should be disallowed

5 participants