feat(sql-formatter): add setting to preserve blank lines
This commit is contained in:
16 files changed
+158
-7
No files matched your search
@@ -109,6 +109,7 @@ const sqlFormatterOptionLabelKeys: Record<keyof SqlFormatterOptionSettings, stri
|
||||
fromClauseLayout: "settings.sqlFormatterFromClauseLayout",
|
||||
expressionWidth: "settings.sqlFormatterExpressionWidth",
|
||||
linesBetweenQueries: "settings.sqlFormatterLinesBetweenQueries",
|
||||
preserveEmptyLines: "settings.sqlFormatterPreserveEmptyLines",
|
||||
denseOperators: "settings.sqlFormatterDenseOperators",
|
||||
newlineBeforeSemicolon: "settings.sqlFormatterNewlineBeforeSemicolon",
|
||||
paramTypes: "settings.sqlFormatterParamTypes",
|
||||
@@ -667,6 +668,11 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
|
||||
<div class="grid gap-3 md:grid-cols-2">
|
||||
<div class="flex items-center justify-between gap-4 rounded-md border bg-muted/20 px-3 py-2">
|
||||
<Label for="sql-formatter-preserve-empty-lines">{{ t("settings.sqlFormatterPreserveEmptyLines") }}</Label>
|
||||
<Switch id="sql-formatter-preserve-empty-lines" :model-value="settings.preserveEmptyLines" @update:model-value="(value: boolean) => updateOption('preserveEmptyLines', value)" />
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between gap-4 rounded-md border bg-muted/20 px-3 py-2">
|
||||
<Label for="sql-formatter-dense-operators">{{ t("settings.sqlFormatterDenseOperators") }}</Label>
|
||||
<Switch id="sql-formatter-dense-operators" :model-value="settings.denseOperators" @update:model-value="(value: boolean) => updateOption('denseOperators', value)" />
|
||||
|
||||
@@ -9,6 +9,7 @@ import { useToast } from "@/composables/useToast";
|
||||
import { copyToClipboard } from "@/lib/common/clipboard";
|
||||
import { formatSqlText, type SqlFormatDialect } from "@/lib/sql/sqlFormatter";
|
||||
import { createShikiSqlHighlighter, type SqlHighlighter } from "@/lib/sql/sqlHighlighter";
|
||||
import { useSettingsStore } from "@/stores/settingsStore";
|
||||
|
||||
const props = defineProps<{
|
||||
sql: string;
|
||||
@@ -27,6 +28,7 @@ const emit = defineEmits<{
|
||||
const { t } = useI18n();
|
||||
const { isDark } = useTheme();
|
||||
const { toast } = useToast();
|
||||
const settingsStore = useSettingsStore();
|
||||
|
||||
const isFormatted = ref(false);
|
||||
const formattedSql = ref("");
|
||||
@@ -79,7 +81,7 @@ async function toggleFormat() {
|
||||
|
||||
formatting.value = true;
|
||||
try {
|
||||
formattedSql.value = await formatSqlText(props.sql, props.sqlFormatDialect ?? "generic");
|
||||
formattedSql.value = await formatSqlText(props.sql, props.sqlFormatDialect ?? "generic", settingsStore.editorSettings.sqlFormatter);
|
||||
isFormatted.value = true;
|
||||
await highlightSql();
|
||||
} catch {
|
||||
|
||||
Reference in new issue
Block a user