Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

/**
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}));
}
}