Skip to content
Closed
Show file tree
Hide file tree
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
32 changes: 30 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,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();

Expand Down Expand Up @@ -1086,9 +1085,17 @@ export default class VaultCrdtSyncPlugin extends Plugin {
this.log(`importUntracked: "${path}" now in CRDT, skipping`);
continue;
}
if (!this.isMarkdownPathSyncable(path)) {
this.log(`importUntracked: "${path}" no longer syncable, skipping`);
continue;
}

const file = this.app.vault.getAbstractFileByPath(path);
if (!(file instanceof TFile)) continue;
if (this.maxFileSize > 0 && file.stat.size > this.maxFileSize) {
this.log(`importUntracked: "${path}" now exceeds file-size limit, skipping`);
continue;
}

try {
const content = await this.app.vault.read(file);
Expand Down Expand Up @@ -2415,6 +2422,27 @@ export default class VaultCrdtSyncPlugin extends Plugin {
}
}

/** Refresh derived runtime filters after persisted settings change. */
refreshRuntimeSettings(): void {
this.excludePatterns = parseExcludePatterns(this.settings.excludePatterns);
this.maxFileSize = this.settings.maxFileSizeKB * 1024;
this.refreshUntrackedFileFilters();
}

private refreshUntrackedFileFilters(): void {
const before = this.untrackedFiles.length;
this.untrackedFiles = this.untrackedFiles.filter((path) => {
if (!this.isMarkdownPathSyncable(path)) return false;
const file = this.app.vault.getAbstractFileByPath(path);
if (!(file instanceof TFile)) return false;
return this.maxFileSize <= 0 || file.stat.size <= this.maxFileSize;
});
const removed = before - this.untrackedFiles.length;
if (removed > 0) {
this.log(`Filtered ${removed} stale untracked file(s) after settings refresh`);
}
}

/**
* Toggle remote cursor visibility via a CSS class on the document body.
* The actual cursor styles from y-codemirror.next are hidden when the
Expand Down
4 changes: 3 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}),
);

Expand All @@ -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();
}
}),
);
Expand Down
Loading