Skip to content

Single line arrays defined as multi line are expanded even though 'array_auto_expand = false' #764

Open
@jzenoz

Description

@jzenoz

Hi, not sure if I'm missing something but looking at the TOML spec for arrays:

https://toml.io/en/v1.0.0#array

And using the example there of an array defined across multiple lines but containing only a single line:

integers = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ]
integers2 = [
  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
]

With .taplo.toml configuration:

[formatting]
array_auto_expand = false
array_auto_collapse = false
compact_arrays = false
column_width = 80

There seems to be no way to disable the expanding of integers2?

jz:~/scratch$ docker run --rm --tty --volume $PWD:$PWD --workdir $PWD tamasfe/taplo:0.9.3 format --check --diff test.toml
 INFO taplo:format_files:load_config: found configuration file path="/home/jz/scratch/.taplo.toml"
 INFO taplo:format_files:collect_files: found files total=1 excluded=0 cwd="/home/jz/scratch"
diff a//home/jz/scratch/test.toml b//home/jz/scratch/test.toml
--- a//home/jz/scratch/test.toml
+++ b//home/jz/scratch/test.toml
@@ -0,2 +0,2 @@
integers = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ]
integers2 = [
@@ -2,1 +2,20 @@
-  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
+  1,
+  2,
+  3,
+  4,
+  5,
+  6,
+  7,
+  8,
+  9,
+  10,
+  11,
+  12,
+  13,
+  14,
+  15,
+  16,
+  17,
+  18,
+  19,
+  20,
@@ -3,1 +22,1 @@
]
ERROR taplo:format_files: the file is not properly formatted path="/home/jz/scratch/test.toml"
ERROR operation failed error=some files were not properly formatted

No matter what I throw at .taplo.toml the above occurs, if I set array_auto_collapse = true the array is collapsed instead but I want it left alone.

My particular usecase is a configuration like:

data = [
  test, test, test, test, test, test, test, test,
  test, test, test, test, test, test, test, test,
]

Where it's easy to add lines each containing 8 sets of data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions