Falcion / UNITADE.md

A plugin for note-taking app Obsidian™ which allows you to treat any file extension as markdown note-file
MIT License
49 stars 0 forks source link

[BUG]: grouped extension bug of view-render (parallel loading of extensions with a regular loader) #31

Closed Falcion closed 4 months ago

Falcion commented 5 months ago

Contact details

No response

What the essence of the bug

Grouped extensions module is throwing errors in console and notifications: all extensions already rendered as markdown, this is critical bug even within context of notice before usage of this module.

Example

plugin:unitade:707 Error: Attempting to register an existing view type "exe"
    at t.registerView (app.js:1:1986951)
    at t.registerView (app.js:1:2238139)
    at _UNITADE_PLUGIN.__apply (plugin:unitade:702:14)
    at _UNITADE_PLUGIN.eval (plugin:unitade:683:12)
    at Generator.next (<anonymous>)
    at fulfilled (plugin:unitade:60:24)

Solution:

  1. Rewrite __applyCfg() function and remove preset of view: 'markdown in it's code;
  2. Call __applyCfg() and not __tryApply() in grouped extension module within array by key or just extensions by view;

Starting from L#175 of main.ts:


private __apply(): void {
        if (this.settings.is_grouped) {
            const data: { [key: string]: string[] } = parsegroup(this.settings.grouped_extensions);

            for (const view in data) {
                this.__applyCfg(data[view].join(';'), view);
            }
        }

        if (this.is_mobile) {
            this.__applyCfg(this.settings.mobile_settings.extensions ?? this.settings.extensions, 'markdown');
        } else {
            this.__applyCfg(this.settings.extensions, 'markdown');
        }

        const forced_extensions = this.settings.forced_extensions.split(';').map(s => s.trim());

        for (const extension of forced_extensions) {
            try {
                this.registerView(extension, (leaf: WorkspaceLeaf) => {
                    return new UNITADE_VIEW(leaf, extension);
                });
            } catch (err: any) {
                new Notification('Error from UNITADE plugin:', { body: `${err}` });

                console.error(err);
            }
        }
    }

This is not perfect clear solution, but it fixes the global problem of parallel rendering everything as markdown.

Version of an project's essence

2.0.0

On what OS you have encountered the bug.

Windows

Code of conduct

Issue policy

Falcion commented 4 months ago

Fixed in last release (v2.1.0).