fix(sql-file): cache preview highlighting during progress updates

Refs: #9537
This commit is contained in:
t8y2 committed 2026-09-22 19:05:00 +08:00
1 parent c1f2bbda44
commit fc19cae39c
2 files changed
+72 -2

No files matched your search

@@ -62,6 +62,7 @@ watch(previews, (list) => {
const activePreview = computed<SqlFilePreview | null>(() => {
return previews.value.find((item) => item.filePath === activePreviewPath.value) ?? previews.value[0] ?? null;
});
const activePreviewHtml = computed(() => (activePreview.value ? highlight(activePreview.value.preview) : ""));
// Disambiguate files that share the same fileName.
// Desktop: prepend parent directory segments until unique (e.g. migration/create.sql).
@@ -847,7 +848,7 @@ watch(
<div class="sticky left-0 z-10 select-none border-r bg-background/95 px-2 py-3 text-right font-mono leading-5 text-muted-foreground/70">
<div v-for="n in previewLineCount(activePreview)" :key="n">{{ n }}</div>
</div>
<pre class="min-w-max flex-1 p-3 font-mono leading-5 whitespace-pre" v-html="highlight(activePreview.preview)"></pre>
<pre class="min-w-max flex-1 p-3 font-mono leading-5 whitespace-pre" v-html="activePreviewHtml"></pre>
</div>
</div>
</div>