From dc0087845355222d1cbf2820289444db3eebc87e Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 20 Jul 2026 18:19:24 +0900 Subject: fix(json-file): forward detected indent into write's encode options JsonFile::write_with_options() used the caller-supplied JsonEncodeOptions verbatim, ignoring self.indent (set by read()'s detect_indenting), unlike PHP's write() which always passes $this->indent to encode() regardless of the $options argument. Un-ignore test_preserve_indentation_after_read. --- crates/shirabe/src/json/json_file.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'crates/shirabe/src/json') diff --git a/crates/shirabe/src/json/json_file.rs b/crates/shirabe/src/json/json_file.rs index 0ce55e55..91e0d380 100644 --- a/crates/shirabe/src/json/json_file.rs +++ b/crates/shirabe/src/json/json_file.rs @@ -220,6 +220,11 @@ impl JsonFile { hash: PhpMixed, options: JsonEncodeOptions, ) -> anyhow::Result<()> { + let options = JsonEncodeOptions { + indent: self.indent.clone(), + ..options + }; + if self.path == "php://memory" { file_put_contents( &self.path, -- cgit v1.3.1