diff --git a/src/main.ts b/src/main.ts index 68f8fa6..78e1b8c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,8 +6,7 @@ import { LatexSuiteSettingTab } from "./settings/settings_tab"; import { ICONS } from "./settings/ui/icons"; import { getEditorCommands } from "./features/editor_commands"; -import { iterateCM6 } from "./utils/editor_utils"; -import { getLatexSuiteConfigExtension, reconfigureLatexSuiteConfig } from "./snippets/codemirror/config"; +import { getLatexSuiteConfigExtension } from "./snippets/codemirror/config"; import { SnippetVariables, parseSnippetVariables, parseSnippets } from "./snippets/parse"; import { handleUpdate, onKeydown } from "./latex_suite"; import { EditorView, tooltips } from "@codemirror/view"; @@ -148,20 +147,11 @@ export default class LatexSuitePlugin extends Plugin { async processSettings(becauseFileLocationUpdated = false, becauseFileUpdated = false) { this.CMSettings = processLatexSuiteSettings(await this.getSnippets(becauseFileLocationUpdated, becauseFileUpdated), this.settings); - this.reconfigureLatexSuiteConfig(); this.setEditorExtensions(); // Request Obsidian to reconfigure CM extensions this.app.workspace.updateOptions(); } - reconfigureLatexSuiteConfig() { - iterateCM6(this.app.workspace, (view) => { - view.dispatch({ - effects: reconfigureLatexSuiteConfig(this.CMSettings) - }); - }) - } - // Set 'this.editorExtensions' based on the contents of 'this.CMSettings' setEditorExtensions() { // Remove all currently loaded CM extensions diff --git a/src/snippets/codemirror/config.ts b/src/snippets/codemirror/config.ts index e87816d..9ac3f20 100644 --- a/src/snippets/codemirror/config.ts +++ b/src/snippets/codemirror/config.ts @@ -1,5 +1,5 @@ import { EditorView } from "@codemirror/view"; -import { Facet, Compartment, EditorState } from "@codemirror/state"; +import { Facet, EditorState } from "@codemirror/state"; import { LatexSuiteCMSettings, processLatexSuiteSettings, DEFAULT_SETTINGS } from "src/settings/settings"; export const latexSuiteConfig = Facet.define({ @@ -15,12 +15,6 @@ export function getLatexSuiteConfig(viewOrState: EditorView | EditorState) { return state.facet(latexSuiteConfig); } -export const latexSuiteConfigCompartment = new Compartment(); - export function getLatexSuiteConfigExtension(pluginSettings: LatexSuiteCMSettings) { - return latexSuiteConfigCompartment.of(latexSuiteConfig.of(pluginSettings)); + return latexSuiteConfig.of(pluginSettings); } - -export function reconfigureLatexSuiteConfig(pluginSettings: LatexSuiteCMSettings) { - return latexSuiteConfigCompartment.reconfigure(latexSuiteConfig.of(pluginSettings)); -} \ No newline at end of file diff --git a/src/utils/editor_utils.ts b/src/utils/editor_utils.ts index 88f451f..1cdc94d 100644 --- a/src/utils/editor_utils.ts +++ b/src/utils/editor_utils.ts @@ -1,4 +1,4 @@ -import { Platform, Workspace, MarkdownView } from "obsidian"; +import { Platform } from "obsidian"; import { EditorView } from "@codemirror/view"; import { SyntaxNode, TreeCursor } from "@lezer/common"; import { EditorState } from "@codemirror/state"; @@ -9,14 +9,6 @@ export function replaceRange(view: EditorView, start: number, end: number, repla }); } -export function iterateCM6(workspace: Workspace, callback: (editor: EditorView) => unknown) { - workspace.iterateAllLeaves(leaf => { - leaf?.view instanceof MarkdownView && - (leaf.view.editor as any)?.cm instanceof EditorView && - callback((leaf.view.editor as any).cm); - }); -} - export function getCharacterAtPos(viewOrState: EditorView | EditorState, pos: number) { const state = viewOrState instanceof EditorView ? viewOrState.state : viewOrState; const doc = state.doc;