(ctx context.Context, data wshrpc.CommandResolveIdsData, value string)
| 128 | } |
| 129 | |
| 130 | func resolveTabNum(ctx context.Context, data wshrpc.CommandResolveIdsData, value string) (*waveobj.ORef, error) { |
| 131 | m := simpleTabNumRe.FindStringSubmatch(value) |
| 132 | if m == nil { |
| 133 | return nil, fmt.Errorf("error parsing simple tab id: %s", value) |
| 134 | } |
| 135 | |
| 136 | tabNum, err := strconv.Atoi(m[1]) |
| 137 | if err != nil { |
| 138 | return nil, fmt.Errorf("error parsing simple tab num: %v", err) |
| 139 | } |
| 140 | |
| 141 | curTabId, err := wstore.DBFindTabForBlockId(ctx, data.BlockId) |
| 142 | if err != nil { |
| 143 | return nil, fmt.Errorf("error finding tab for block: %v", err) |
| 144 | } |
| 145 | |
| 146 | wsId, err := wstore.DBFindWorkspaceForTabId(ctx, curTabId) |
| 147 | if err != nil { |
| 148 | return nil, fmt.Errorf("error finding current workspace: %v", err) |
| 149 | } |
| 150 | |
| 151 | ws, err := wstore.DBMustGet[*waveobj.Workspace](ctx, wsId) |
| 152 | if err != nil { |
| 153 | return nil, fmt.Errorf("error getting workspace: %v", err) |
| 154 | } |
| 155 | |
| 156 | numTabs := len(ws.TabIds) |
| 157 | if tabNum < 1 || tabNum > numTabs { |
| 158 | return nil, fmt.Errorf("tab num out of range, workspace has %d tabs", numTabs) |
| 159 | } |
| 160 | |
| 161 | tabIdx := tabNum - 1 |
| 162 | resolvedTabId := ws.TabIds[tabIdx] |
| 163 | return &waveobj.ORef{OType: waveobj.OType_Tab, OID: resolvedTabId}, nil |
| 164 | } |
| 165 | |
| 166 | func resolveBlock(ctx context.Context, data wshrpc.CommandResolveIdsData, value string) (*waveobj.ORef, error) { |
| 167 | blockNum, err := strconv.Atoi(value) |
no test coverage detected