diff --git a/pkg/waveobj/ctxupdate.go b/pkg/waveobj/ctxupdate.go index 7bce8102c..5ee01fdab 100644 --- a/pkg/waveobj/ctxupdate.go +++ b/pkg/waveobj/ctxupdate.go @@ -135,3 +135,19 @@ func ContextGetUpdatesRtn(ctx context.Context) UpdatesRtnType { } return rtn } + +func ContextPrintUpdates(ctx context.Context) { + updatesVal := ctx.Value(waveObjUpdateKey) + if updatesVal == nil { + log.Print("no updates\n") + return + } + updates := updatesVal.(*contextUpdatesType) + log.Printf("updates len:%d\n", len(updates.UpdatesStack)) + for idx, update := range updates.UpdatesStack { + log.Printf(" update[%d]:\n", idx) + for k, v := range update { + log.Printf(" %s:%s %s\n", k.OType, k.OID, v.UpdateType) + } + } +} diff --git a/pkg/wshrpc/wshserver/wshserver.go b/pkg/wshrpc/wshserver/wshserver.go index be4f1f16d..82e8daffa 100644 --- a/pkg/wshrpc/wshserver/wshserver.go +++ b/pkg/wshrpc/wshserver/wshserver.go @@ -269,8 +269,6 @@ func (ws *WshServer) CreateBlockCommand(ctx context.Context, data wshrpc.Command return nil, fmt.Errorf("error creating block: %w", err) } blockRef := &waveobj.ORef{OType: waveobj.OType_Block, OID: blockData.OID} - updates := waveobj.ContextGetUpdatesRtn(ctx) - sendWStoreUpdatesToEventBus(updates) windowId, err := wstore.DBFindWindowForTabId(ctx, tabId) if err != nil { return nil, fmt.Errorf("error finding window for tab: %w", err) @@ -278,12 +276,17 @@ func (ws *WshServer) CreateBlockCommand(ctx context.Context, data wshrpc.Command if windowId == "" { return nil, fmt.Errorf("no window found for tab") } - wlayout.QueueLayoutActionForTab(ctx, tabId, waveobj.LayoutActionData{ + err = wlayout.QueueLayoutActionForTab(ctx, tabId, waveobj.LayoutActionData{ ActionType: wlayout.LayoutActionDataType_Insert, BlockId: blockRef.OID, Magnified: data.Magnified, Focused: true, }) + if err != nil { + return nil, fmt.Errorf("error queuing layout action: %w", err) + } + updates := waveobj.ContextGetUpdatesRtn(ctx) + sendWStoreUpdatesToEventBus(updates) return &waveobj.ORef{OType: waveobj.OType_Block, OID: blockRef.OID}, nil }