swiftlang / swiftlang/swift-syntax

BasicFormat should automatically determine indentation level of a file

Open
#1,474 7 comments 0 reactions 0 assignees View on GitHub
BasicFormat enhancement
Dominant language
Swift
Stars
3.7k
Forks
553
Avg merge
5d 13h
Merged PRs (30d)
16

Description

### Description

We could take a pretty good guess on the indentation of the file.

There's a few ways we could do this. One would be to grab the indentation up to content in each line, then divide that by common indents and pick the closest match. This is probably good enough, but we can always get more accurate by eg. skipping multiline strings, or rather than an average, instead look at how many lines fit that indentation.

Contributor guide

Open the contributing guide

Research direction

Start by locating the BasicFormat entry point and reading how indentation is currently selected. Compare the proposed approaches for estimating indentation from line content, including how multiline strings would affect the result. Done means BasicFormat can infer a file's indentation reliably, with tests covering representative indentation patterns.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.