Unified merge view: RangeError Field is not present in this state #1167

Closed
opened 2023-05-18 19:49:49 +02:00 by grafail · 3 comments
grafail commented 2023-05-18 19:49:49 +02:00 (Migrated from github.com)

Describe the issue

I am using Codemirror with the vue-codemirror package. It seems that adding the unified merge view extension in the prop field is creating an issue.

<VueCodemirror
      modelValue="123"
      :extensions="[unifiedMergeView({ original: 'test' })]"
    />

Per my understanding, I suspect this is because vue-codemirror initialises some basic extensions first and then reconfigures to add the extensions passed in the prop.
The extension works if added when in the list of extensions initialised in the first step (i.e. when registering the module globally in Vue)

Trace:

RangeError: Field is not present in this state
    field index.cjs:2580
    update index.cjs:1510
    update index.cjs:1803
    applyTransaction index.cjs:2636
    ensureAddr index.cjs:2039
    EditorState index.cjs:2573
    applyTransaction index.cjs:2636
    get state index.cjs:2286
    update index.cjs:6623
    _dispatch index.cjs:6584
    dispatch index.cjs:6605
    run vue-codemirror.cjs.js:7
    setup vue-codemirror.cjs.js:7
    callWithErrorHandling runtime-core.esm-bundler.js:1017
    callWithAsyncErrorHandling runtime-core.esm-bundler.js:1025
    job runtime-core.esm-bundler.js:2256
    doWatch runtime-core.esm-bundler.js:2281
    watch runtime-core.esm-bundler.js:2164
    setup vue-codemirror.cjs.js:7
    createHook runtime-core.esm-bundler.js:2998
    callWithErrorHandling runtime-core.esm-bundler.js:1017
    callWithAsyncErrorHandling runtime-core.esm-bundler.js:1025
    __weh runtime-core.esm-bundler.js:2982
    flushPostFlushCbs runtime-core.esm-bundler.js:1172
    render runtime-core.esm-bundler.js:5609
    mount runtime-core.esm-bundler.js:4288
    mount runtime-dom.esm-bundler.js:1465
    $csb$eval main.js:20
    H eval.js:31
    evaluate transpiled-module.js:715
    evaluateTranspiledModule manager.js:340
    evaluateModule manager.js:311
    e compile.ts:833
    c runtime.js:45
    _invoke runtime.js:274
    r runtime.js:97
    Babel 2
index.js:27:25

Browser and platform

No response

https://codesandbox.io/s/nifty-hooks-2p2n0g?file=/src/components/HelloWorld.vue

### Describe the issue I am using Codemirror with the `vue-codemirror` package. It seems that adding the unified merge view extension in the prop field is creating an issue. ```vue <VueCodemirror modelValue="123" :extensions="[unifiedMergeView({ original: 'test' })]" /> ``` Per my understanding, I suspect this is because vue-codemirror initialises some basic extensions first and then reconfigures to add the extensions passed in the prop. The extension works if added when in the list of extensions initialised in the first step (i.e. when registering the module globally in Vue) Trace: ``` RangeError: Field is not present in this state field index.cjs:2580 update index.cjs:1510 update index.cjs:1803 applyTransaction index.cjs:2636 ensureAddr index.cjs:2039 EditorState index.cjs:2573 applyTransaction index.cjs:2636 get state index.cjs:2286 update index.cjs:6623 _dispatch index.cjs:6584 dispatch index.cjs:6605 run vue-codemirror.cjs.js:7 setup vue-codemirror.cjs.js:7 callWithErrorHandling runtime-core.esm-bundler.js:1017 callWithAsyncErrorHandling runtime-core.esm-bundler.js:1025 job runtime-core.esm-bundler.js:2256 doWatch runtime-core.esm-bundler.js:2281 watch runtime-core.esm-bundler.js:2164 setup vue-codemirror.cjs.js:7 createHook runtime-core.esm-bundler.js:2998 callWithErrorHandling runtime-core.esm-bundler.js:1017 callWithAsyncErrorHandling runtime-core.esm-bundler.js:1025 __weh runtime-core.esm-bundler.js:2982 flushPostFlushCbs runtime-core.esm-bundler.js:1172 render runtime-core.esm-bundler.js:5609 mount runtime-core.esm-bundler.js:4288 mount runtime-dom.esm-bundler.js:1465 $csb$eval main.js:20 H eval.js:31 evaluate transpiled-module.js:715 evaluateTranspiledModule manager.js:340 evaluateModule manager.js:311 e compile.ts:833 c runtime.js:45 _invoke runtime.js:274 r runtime.js:97 Babel 2 index.js:27:25 ``` ### Browser and platform _No response_ ### Reproduction link https://codesandbox.io/s/nifty-hooks-2p2n0g?file=/src/components/HelloWorld.vue
grafail commented 2023-05-19 14:13:05 +02:00 (Migrated from github.com)

I made a pull request that seems to fix the issue

I made a pull request that seems to fix the issue
marijnh commented 2023-05-19 16:24:00 +02:00 (Migrated from github.com)

Thanks for diagnosing that! I applied a slightly different patch that doesn't introduce the dependency on unified.ts and mergeview.ts.

Thanks for diagnosing that! I applied a slightly different patch that doesn't introduce the dependency on unified.ts and mergeview.ts.
grafail commented 2023-05-19 17:21:09 +02:00 (Migrated from github.com)

Thank you!

Thank you!
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/dev#1167
No description provided.