sqlformat-rs
sqlformat-rs copied to clipboard
Allow leading indentation for queries
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?