Skip to content

Allow leading indentation for queries #56

Open

Description

@pcmantz

It is common in editors to highlight a specific line or region of code, pass it through a formatter, and replace the highlighted region with the output of the formatter. If sqlformat-rs can support preserving the leading indentation of an expression, then it'd be possible to format nested subsections of a larger block of code without touching the rest of the file. This would make it easier to edit SQL where there are structural elements that sqlformat-rs doesn't support as well.

I am a pretty new rust programmer, but it looks like implementing this would involve adding a preserve_indent flag to FormatOptions, have the parser read in the amount of whitespace on the first line, and call increase_top_level with the right amount of indentation when reading the first line. Would that be correct?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions