From 9d305bcf0d940a1309027ea84922a23169677e54 Mon Sep 17 00:00:00 2001 From: Bram Hoendervangers Date: Tue, 10 Oct 2023 16:17:21 +0200 Subject: [PATCH] chore: rename printer setting to for consistency --- formatter/src/formatter/mod.rs | 3 ++- printer/src/algorithm.rs | 7 ++++--- printer/src/convenience.rs | 11 ++++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/formatter/src/formatter/mod.rs b/formatter/src/formatter/mod.rs index 8271ccc..1289f26 100644 --- a/formatter/src/formatter/mod.rs +++ b/formatter/src/formatter/mod.rs @@ -91,7 +91,7 @@ impl FormatterSettings { pub fn to_printer_settings(&self, source: Option<&Rope>) -> PrinterSettings { PrinterSettings { margin: self.max_width as isize, - spaces: self.tab_spaces as isize, + tab_spaces: self.tab_spaces as isize, min_space: 60, crlf_line_endings: match self.newline_style { NewlineStyle::Auto => source.map(uses_crlf_line_ending).unwrap_or_default(), @@ -184,3 +184,4 @@ impl<'a> Formatter<'a> { self.line_offset = Some(line_index); } } + diff --git a/printer/src/algorithm.rs b/printer/src/algorithm.rs index 8b1bb07..c10b7c9 100644 --- a/printer/src/algorithm.rs +++ b/printer/src/algorithm.rs @@ -50,7 +50,7 @@ pub struct PrinterSettings { // Target line width. pub margin: isize, // Number of spaces incement at each level of block indentation. - pub spaces: isize, + pub tab_spaces: isize, // Every line is allowed at least this much space, even if highly indented. pub min_space: isize, // Print CRLF line ending instead of LF @@ -361,8 +361,8 @@ impl Printer { if !self.settings.hard_tabs { self.out.reserve(self.pending_indentation); } else { - let tabs = self.pending_indentation / self.settings.spaces as usize; - let remaining_spaces = self.pending_indentation % self.settings.spaces as usize; + let tabs = self.pending_indentation / self.settings.tab_spaces as usize; + let remaining_spaces = self.pending_indentation % self.settings.tab_spaces as usize; self.out.reserve(tabs + remaining_spaces); self.out.extend(iter::repeat('\t').take(tabs)); self.pending_indentation = remaining_spaces @@ -373,3 +373,4 @@ impl Printer { self.pending_indentation = 0; } } + diff --git a/printer/src/convenience.rs b/printer/src/convenience.rs index aa41cac..f3435f9 100644 --- a/printer/src/convenience.rs +++ b/printer/src/convenience.rs @@ -3,11 +3,11 @@ use std::borrow::Cow; impl Printer { pub fn ibox_indent(&mut self) { - self.ibox(self.settings.spaces); + self.ibox(self.settings.tab_spaces); } pub fn ibox_dedent(&mut self) { - self.ibox(-self.settings.spaces); + self.ibox(-self.settings.tab_spaces); } pub fn ibox(&mut self, indent: isize) { @@ -18,11 +18,11 @@ impl Printer { } pub fn cbox_indent(&mut self) { - self.cbox(self.settings.spaces); + self.cbox(self.settings.tab_spaces); } pub fn cbox_dedent(&mut self) { - self.cbox(-self.settings.spaces); + self.cbox(-self.settings.tab_spaces); } pub fn cbox(&mut self, indent: isize) { @@ -33,7 +33,7 @@ impl Printer { } pub fn end_dedent(&mut self) { - self.offset(-self.settings.spaces); + self.offset(-self.settings.tab_spaces); self.end(); } @@ -117,3 +117,4 @@ impl Printer { }); } } +