Skip to content

Commit b0e0228

Browse files
authored
feat: make cell padding configurable (#32)
1 parent e638d46 commit b0e0228

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Working with CSV files shouldn’t be a chore. With CSV, you get:
7474
- **Improved:** Navigation and editing, including better handling of special characters like quotes and commas.
7575
- **Added:** Advanced column type detection with dynamic color-coded highlighting.
7676
- **Refined:** Update mechanism for external document changes without interrupting your workflow.
77+
- **Configurable:** Added `csv.cellPadding` setting to adjust table cell padding.
7778

7879
### v1.0.2
7980
- **Improved:** Seamless activation of editing mode on double-click.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,15 @@
6565
"default": ",",
6666
"description": "CSV separator to use."
6767
},
68-
"csv.fontFamily": {
68+
"csv.fontFamily": {
6969
"type": "string",
7070
"default": "Menlo",
7171
"description": "CSV Font Family to use."
72+
},
73+
"csv.cellPadding": {
74+
"type": "number",
75+
"default": 4,
76+
"description": "Vertical padding in pixels for table cells."
7277
}
7378
}
7479
},

src/extension.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,11 @@ class CsvEditorProvider implements vscode.CustomTextEditorProvider {
219219
result = { data: [] };
220220
}
221221
const fontFamily = config.get<string>('fontFamily', 'Menlo');
222+
const cellPadding = config.get<number>('cellPadding', 4);
222223
const data = result.data as string[][];
223224
const htmlContent = this.generateHtmlContent(data, treatHeader, addSerialIndex, fontFamily);
224225
const nonce = getNonce();
225-
this.currentWebviewPanel!.webview.html = this.wrapHtml(htmlContent, nonce, fontFamily);
226+
this.currentWebviewPanel!.webview.html = this.wrapHtml(htmlContent, nonce, fontFamily, cellPadding);
226227
}
227228

228229
/**
@@ -296,7 +297,7 @@ class CsvEditorProvider implements vscode.CustomTextEditorProvider {
296297
/**
297298
* Wraps the provided HTML content in a complete HTML document with a strict Content Security Policy.
298299
*/
299-
private wrapHtml(content: string, nonce: string, fontFamily: string): string {
300+
private wrapHtml(content: string, nonce: string, fontFamily: string, cellPadding: number): string {
300301
const isDark = vscode.window.activeColorTheme.kind === vscode.ColorThemeKind.Dark;
301302
return `<!DOCTYPE html>
302303
<html>
@@ -309,7 +310,7 @@ class CsvEditorProvider implements vscode.CustomTextEditorProvider {
309310
body { font-family: "${fontFamily}"; margin: 0; padding: 0; user-select: none; }
310311
.table-container { overflow-x: auto; max-height: 100vh; }
311312
table { border-collapse: collapse; width: max-content; }
312-
th, td { padding: 4px 8px; border: 1px solid #555; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
313+
th, td { padding: ${cellPadding}px 8px; border: 1px solid #555; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
313314
th { position: sticky; top: 0; background-color: ${isDark ? '#1e1e1e' : '#ffffff'}; }
314315
td.selected, th.selected { background-color: ${isDark ? '#333333' : '#cce0ff'} !important; }
315316
td.editing, th.editing { overflow: visible !important; white-space: normal !important; max-width: none !important; }

0 commit comments

Comments
 (0)