From 7ea483fe26fb716232655e1d1b7eb7778eca8380 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 1 Dec 2025 23:09:58 -0500 Subject: [PATCH] fmt: fix write_char not respecting indent string take default indent string from env! --- src/fmt.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/fmt.rs b/src/fmt.rs index eb5690e..e19cbc0 100644 --- a/src/fmt.rs +++ b/src/fmt.rs @@ -2,11 +2,19 @@ use std::fmt::{Display, Write}; +/// The default indentation string. Defaults to four spaces. +const INDENTATION: &str = { + match option_env!("DOUGHLANG_INDENT") { + Some(indent) => indent, + None => " ", + } +}; + impl FmtAdapter for W {} pub trait FmtAdapter: Write { /// Indents by one level. fn indent(&mut self) -> Indent<'_, Self> { - Indent::new(self, " ") + Indent::new(self, INDENTATION) } /// Pastes `indent` after each newline. @@ -99,7 +107,7 @@ impl Write for Indent<'_, F> { } fn write_char(&mut self, c: char) -> std::fmt::Result { if self.needs_indent { - self.f.write_str(" ")?; + self.f.write_str(self.indent)?; } self.needs_indent = c == '\n'; self.f.write_char(c)