Skip to content

Commit 951ea85

Browse files
committed
allow editing empty csv
1 parent 8ebce74 commit 951ea85

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/extension.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -347,17 +347,12 @@ class CsvEditorProvider implements vscode.CustomTextEditorProvider {
347347
* Generates an HTML table from CSV data.
348348
*/
349349
private generateHtmlContent(data: string[][], treatHeader: boolean, addSerialIndex: boolean, fontFamily: string): string {
350+
/* ──────── NEW: ensure at least one editable cell ──────── */
350351
if (data.length === 0) {
351-
return `<!DOCTYPE html>
352-
<html>
353-
<head>
354-
<meta charset="UTF-8">
355-
<title>CSV</title>
356-
<style>body { font-family: ${fontFamily}; padding: 10px; }</style>
357-
</head>
358-
<body><p>No data found in CSV.</p></body>
359-
</html>`;
352+
data.push(['']); // single empty row + cell
353+
treatHeader = false; // no header in an empty sheet
360354
}
355+
361356
const isDark = vscode.window.activeColorTheme.kind === vscode.ColorThemeKind.Dark;
362357
const headerRow = treatHeader ? data[0] : [];
363358
const bodyData = treatHeader ? data.slice(1) : data;

0 commit comments

Comments
 (0)