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 #2091

Merged
merged 2 commits into from
Oct 9, 2023
Merged

Fix editor extension settings not properly reflected #2091

merged 2 commits into from
Oct 9, 2023

Conversation

RyotaUshio
Copy link
Contributor

@RyotaUshio RyotaUshio commented Oct 7, 2023

Bug description

  1. If both "Enable Inline Queries" (settings.enableInlineDataview) and "Enable Inline JavaScript Queries" (settings.enableInlineDataviewJS) are turned off 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).

Steps to reproduce bug 1

  1. Turn off "Enable Inline Queries" and "Enable Inline JavaScript Queries".
  2. Disable Dataview
  3. Enable Dataview
  4. Turn on "Enable Inline Queries" and "Enable Inline JavaScript Queries". Now, inline queries should be rendered in live preview, but they are not.

Solution

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 updated at all after the initial loading.

/** 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. This also resolves 2.

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

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

Thank you!

@blacksmithgu blacksmithgu merged commit 11f4715 into blacksmithgu:master Oct 9, 2023
3 checks passed
@AB1908
Copy link
Collaborator

AB1908 commented Oct 9, 2023

What a champ, CM related fixes are pretty rare. Thanks!

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.

3 participants