Skip to content

id 'tab' for current tabid #891

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/wsh/cmd/wshcmd-root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions pkg/wshrpc/wshserver/wshserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
)

const SimpleId_This = "this"
const SimpleId_Tab = "tab"

var SimpleId_BlockNum_Regex = regexp.MustCompile(`^\d+$`)

Expand Down Expand Up @@ -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)
Expand Down