diff --git a/cmd/wsh/cmd/wshcmd-root.go b/cmd/wsh/cmd/wshcmd-root.go index 411ff08b2..0e9cd2936 100644 --- a/cmd/wsh/cmd/wshcmd-root.go +++ b/cmd/wsh/cmd/wshcmd-root.go @@ -112,7 +112,7 @@ func setTermHtmlMode() { var oidRe = regexp.MustCompile(`^[0-9a-f]{8}$`) func validateEasyORef(oref string) error { - if oref == "this" { + if oref == "this" || oref == "tab" { return nil } if num, err := strconv.Atoi(oref); err == nil && num >= 1 { diff --git a/pkg/wshrpc/wshserver/wshserver.go b/pkg/wshrpc/wshserver/wshserver.go index c599a36b7..f51953ccd 100644 --- a/pkg/wshrpc/wshserver/wshserver.go +++ b/pkg/wshrpc/wshserver/wshserver.go @@ -33,6 +33,7 @@ import ( ) const SimpleId_This = "this" +const SimpleId_Tab = "tab" var SimpleId_BlockNum_Regex = regexp.MustCompile(`^\d+$`) @@ -160,6 +161,16 @@ func resolveSimpleId(ctx context.Context, data wshrpc.CommandResolveIdsData, sim } return &waveobj.ORef{OType: waveobj.OType_Block, OID: data.BlockId}, nil } + if simpleId == SimpleId_Tab { + if data.BlockId == "" { + return nil, fmt.Errorf("no blockid in request") + } + tabId, err := wstore.DBFindTabForBlockId(ctx, data.BlockId) + if err != nil { + return nil, fmt.Errorf("error finding tab: %v", err) + } + return &waveobj.ORef{OType: waveobj.OType_Tab, OID: tabId}, nil + } blockNum, err := strconv.Atoi(simpleId) if err == nil { tabId, err := wstore.DBFindTabForBlockId(ctx, data.BlockId)