codemirror / dev

Development repository for the CodeMirror editor project
https://codemirror.net/
Other
5.44k stars 343 forks source link

How to Maintain dispatch effect #1351

Closed yuanjiexiong closed 3 months ago

yuanjiexiong commented 3 months ago

Describe the issue

I have plugin that use dispatch:

(1) autosuggestion plugin: update.view.dispatch({ effects: InlineSuggestionEffect.of({ text: result, doc: doc }), });

(2)@codemirror/lint plugin: this.view.dispatch(setDiagnostics(this.view.state, diagnostics));

Conflict bug: When lint is enabled, autosuggestion effects disappears(autosuggestiontext disappears). It seem like this.view.dispatch can only maintain the latest effect.

yuanjiexiong commented 3 months ago

I need to use github copilot , so I use autosuggestion library: codemirror-extension-inline-suggestion And I need lsp, so I use @codemirror/lint

codemirror-extension-inline-suggestion Code: https://github.com/saminzadeh/codemirror-extension-inline-suggestion src/extension.ts

https://discuss.codemirror.net/t/how-to-fix-conflict-plugin-dispatch-question/7956

marijnh commented 3 months ago

Since I don't know how your InlineSuggestionEffect works, I don't know what is going on. But no, view.dispatch doesn't just 'maintain the latest effect'. The maintenance of state will be done by a state field in whichever code handles these, and that is where the logic for this will live. I guess you're better off filing an issue or question with the inline-suggestion library, since this isn't an issue in CodeMirror itself.