diff --git a/src/main.ts b/src/main.ts index bbe4d80..6bf5544 100644 --- a/src/main.ts +++ b/src/main.ts @@ -23,12 +23,8 @@ export default class MyPlugin extends Plugin { await this.saveData(this.settings); } - _onEditorChange = async (editor: Editor, _markdownView: MarkdownView) => { - // Settings can change while the editor is open, so we need to reload them. - await this.loadSettings(); - setTimeout(() => { - this._sortTodos(editor); - }, this.settings.delayMS); + _onEditorChange = (editor: Editor, _markdownView: MarkdownView) => { + this._sortTodos(editor); }; _lastSort = new Date(); @@ -43,6 +39,8 @@ export default class MyPlugin extends Plugin { console.error("WARNING!!! Possible infinite sort detected"); return; } + // Settings can change while the editor is open, so we need to reload them. + await this.loadSettings(); const cursor = editor.getCursor(); const lineNumber = cursor.line; const result = sortTodos(value, this.settings.sortOrder); diff --git a/src/settings.ts b/src/settings.ts index 9ee621d..d69f213 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -4,12 +4,10 @@ import { SortOrder } from "./sort"; export interface Settings { sortOrder: SortOrder; - delayMS: number; } export const DEFAULT_SETTINGS: Settings = { sortOrder: SortOrder.COMPLETED_TOP, - delayMS: 0, }; export class SettingsTab extends PluginSettingTab { @@ -34,19 +32,5 @@ export class SettingsTab extends PluginSettingTab { await this.plugin.saveSettings(); }) ); - new Setting(containerEl) - .setName("Delay") - .setDesc("How long to wait after a change until sorting todos?") - .addDropdown((dropdown) => - dropdown - .addOption("0", "No delay") - .addOption("125", "125ms") - .addOption("250", "250ms") - .setValue(this.plugin.settings.delayMS.toString()) - .onChange(async (val) => { - this.plugin.settings.delayMS = parseInt(val, 10); - await this.plugin.saveSettings(); - }) - ); } }