mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +00:00
Respect tab-size
setting in formatter (#8006)
This commit is contained in:
parent
46d5db56cc
commit
4786abac7a
7 changed files with 33 additions and 10 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
use std::borrow::Cow;
|
||||
use std::env::VarError;
|
||||
use std::num::NonZeroU16;
|
||||
use std::num::{NonZeroU16, NonZeroU8};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
|
@ -16,7 +16,7 @@ use shellexpand::LookupError;
|
|||
use strum::IntoEnumIterator;
|
||||
|
||||
use ruff_cache::cache_dir;
|
||||
use ruff_formatter::{IndentStyle, LineWidth};
|
||||
use ruff_formatter::{IndentStyle, IndentWidth, LineWidth};
|
||||
use ruff_linter::line_width::{LineLength, TabSize};
|
||||
use ruff_linter::registry::RuleNamespace;
|
||||
use ruff_linter::registry::{Rule, RuleSet, INCOMPATIBLE_CODES};
|
||||
|
@ -155,7 +155,7 @@ impl Configuration {
|
|||
|
||||
let format = self.format;
|
||||
let format_defaults = FormatterSettings::default();
|
||||
// TODO(micha): Support changing the tab-width but disallow changing the number of spaces
|
||||
|
||||
let formatter = FormatterSettings {
|
||||
exclude: FilePatternSet::try_from_iter(format.exclude.unwrap_or_default())?,
|
||||
preview: match format.preview.unwrap_or(global_preview) {
|
||||
|
@ -169,6 +169,11 @@ impl Configuration {
|
|||
}),
|
||||
line_ending: format.line_ending.unwrap_or(format_defaults.line_ending),
|
||||
indent_style: format.indent_style.unwrap_or(format_defaults.indent_style),
|
||||
indent_width: self
|
||||
.tab_size
|
||||
.map_or(format_defaults.indent_width, |tab_size| {
|
||||
IndentWidth::from(NonZeroU8::from(tab_size))
|
||||
}),
|
||||
quote_style: format.quote_style.unwrap_or(format_defaults.quote_style),
|
||||
magic_trailing_comma: format
|
||||
.magic_trailing_comma
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue