Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix editor extension settings not properly reflected #2090

Closed
wants to merge 3 commits into from
Closed

Fix editor extension settings not properly reflected #2090

wants to merge 3 commits into from

Conversation

RyotaUshio
Copy link
Contributor

@RyotaUshio RyotaUshio commented Oct 7, 2023

Bug description

  1. If neither "Enable Inline Queries" (settings.enableInlineDataview) nor "Enable Inline JavaScript Queries" (settings.enableInlineDataviewJS) is turned on when the plugin's loading, any inline queries are not enabled even if these settings are turned on later on.
  2. Inline fields are rendered regardless of the setting "Enable Inline Fields Highlighting" (settings.prettyRenderInlineFields).

1 is caused by how cmExtension is treated in the plugin's onload method:

// editor extension for inline queries
if (this.settings.enableInlineDataview || this.settings.enableInlineDataviewJs) {
this.cmExtension = [inlinePlugin(this.app, this.index, this.settings, this.api)];
this.registerEditorExtension(this.cmExtension);
}

Here, the comment mentions dynamic updates, but in fact, the editor extensions are not dynamically updated at all.

/** CodeMirror 6 extensions that dataview installs. Tracked via array to allow for dynamic updates. */
private cmExtension: Extension[];

So, I updated main.ts so that the editor extensions are dynamically updated according to the settings.

https://github.com/RyotaUshio/obsidian-dataview/blob/892d343ea9b9845221e2c7ee604ad46bc4d73f0e/src/main.ts#L183-L196

https://github.com/RyotaUshio/obsidian-dataview/blob/892d343ea9b9845221e2c7ee604ad46bc4d73f0e/src/main.ts#L343

Thank you!

@RyotaUshio RyotaUshio closed this Oct 7, 2023
@RyotaUshio RyotaUshio deleted the extensions branch October 7, 2023 07:44
@RyotaUshio
Copy link
Contributor Author

RyotaUshio commented Oct 7, 2023

Sorry, I made this PR from a wrong branch so I'll remake a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant