Skip to content

Commit 6c7eb3d

Browse files
committed
Make sure reconfigurations that change a field's init value update the field
FIX: Fix a bug where reconfiguring a field with a new `init` value didn't update the value of the field. Closes codemirror/dev#1515
1 parent aba3881 commit 6c7eb3d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/facet.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ export class StateField<Value> {
334334
return SlotStatus.Changed
335335
},
336336
reconfigure: (state, oldState) => {
337+
let init = state.facet(initField), oldInit = oldState.facet(initField), reInit
338+
if ((reInit = init.find(i => i.field == this)) && reInit != oldInit.find(i => i.field == this)) {
339+
state.values[idx] = reInit.create(state)
340+
return SlotStatus.Changed
341+
}
337342
if (oldState.config.address[this.id] != null) {
338343
state.values[idx] = oldState.field(this)
339344
return 0

0 commit comments

Comments
 (0)