better-word-count
better-word-count copied to clipboard
Setting text fields to nothing in plugin options breaks plugin
If you set "Page Word Count" to nothing, the setting itself gets set to null
, and then if you reload obsidian you can no longer edit the value of the setting, nor do any settings further down the page appear.
This doesn't appear to be recoverable without manually editing the config file to set pageWords
to an actual number, or alternatively re-installing the plugin.
The error is from this line in src/settings/SettingsTab.ts
:
(Shown code starts on line 51)
new Setting(containerEl)
.setName("Page Word Count")
.setDesc("Set how many words count as one \"page\"")
.addText((text: TextComponent) => {
text.inputEl.type = "number";
text.setPlaceholder("300");
text.setValue(this.plugin.settings.pageWords.toString()); // <-- This line
text.onChange(async (value: string) => {
this.plugin.settings.pageWords = parseInt(value);
await this.plugin.saveSettings();
});
});
I'm assuming it's trying to display/read null
and since that isn't gonna happen it just breaks and the rest of the settings page isn't loaded, including the ability to actually set any settings.
I do not have the knowledge to know what to do with this information, but that is where the problem is.
For posterity, this error occurs with version 0.10.0
, but that doesn't seem super relevant to the actual issue lol.