From 42da4dd0720b98b37c6ed1b612487b3a85d67986 Mon Sep 17 00:00:00 2001 From: enieuwy Date: Tue, 14 Apr 2026 03:48:54 +0800 Subject: [PATCH] fix: refresh runtime excludePatterns and maxFileSize on settings change Settings onChange handlers saved the raw values but never re-parsed them into the runtime fields used by the sync engine. Exclude patterns and max file size only took effect after a plugin reload. Extract refreshRuntimeSettings() and call it from both onChange handlers and onload(). --- src/main.ts | 7 +++++-- src/settings.ts | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index ece4643..6021668 100644 --- a/src/main.ts +++ b/src/main.ts @@ -392,8 +392,7 @@ export default class VaultCrdtSyncPlugin extends Plugin { } // Parse exclude patterns and file size limit from settings - this.excludePatterns = parseExcludePatterns(this.settings.excludePatterns); - this.maxFileSize = this.settings.maxFileSizeKB * 1024; + this.refreshRuntimeSettings(); this.applyCursorVisibility(); @@ -2320,6 +2319,10 @@ export default class VaultCrdtSyncPlugin extends Plugin { * The actual cursor styles from y-codemirror.next are hidden when the * class is absent; we add it when showRemoteCursors is true. */ + refreshRuntimeSettings(): void { + this.excludePatterns = parseExcludePatterns(this.settings.excludePatterns); + this.maxFileSize = this.settings.maxFileSizeKB * 1024; + } applyCursorVisibility(): void { document.body.toggleClass( "vault-crdt-show-cursors", diff --git a/src/settings.ts b/src/settings.ts index 45b8a18..0735c9d 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -463,7 +463,8 @@ export class VaultSyncSettingTab extends PluginSettingTab { .setValue(this.plugin.settings.excludePatterns) .onChange(async (value) => { this.plugin.settings.excludePatterns = value; - await this.plugin.saveSettings(); + await this.plugin.saveSettings(); + this.plugin.refreshRuntimeSettings(); }), ); @@ -479,6 +480,7 @@ export class VaultSyncSettingTab extends PluginSettingTab { if (!isNaN(n) && n > 0) { this.plugin.settings.maxFileSizeKB = n; await this.plugin.saveSettings(); + this.plugin.refreshRuntimeSettings(); } }), );