diff --git a/src/main.ts b/src/main.ts index 0880683..f2da371 100644 --- a/src/main.ts +++ b/src/main.ts @@ -22,12 +22,14 @@ interface SimpleTableMathSettings { fractions: number; locale: string | null; styleLastRow: boolean; + skipHeaderRow: boolean; } const DEFAULT_SETTINGS: SimpleTableMathSettings = { fractions: 2, locale: null, styleLastRow: true, + skipHeaderRow: false, } /** @@ -156,7 +158,8 @@ export default class SimpleTableMath extends Plugin { } if (direction === '^') { - const actualStartRow = Math.max(0, startIndex); + const minStartRow = this.settings.skipHeaderRow ? 1 : 0; + const actualStartRow = Math.max(minStartRow, startIndex); const actualEndRow = endIndex !== -1 ? endIndex : rowIndex - 1; const finalEndRow = Math.min(actualEndRow, rowIndex - 1); if (actualStartRow <= finalEndRow) { @@ -422,5 +425,15 @@ class SettingTab extends PluginSettingTab { this.plugin.settings.styleLastRow = value; await this.plugin.saveSettings(); })); + + new Setting(containerEl) + .setName('Skip header row') + .setDesc('When enabled, the first row of each table will be excluded from vertical (^) calculations. Useful when your header row contains numbers.') + .addToggle(component => component + .setValue(this.plugin.settings.skipHeaderRow) + .onChange(async (value) => { + this.plugin.settings.skipHeaderRow = value; + await this.plugin.saveSettings(); + })); } }