MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / getNextTabName

Function getNextTabName

pkg/wcore/workspace.go:204–220  ·  view source on GitHub ↗

getNextTabName returns the next auto-generated tab name (e.g. "T3") given a slice of existing tab names. It filters to names matching T[N] where N is a positive integer, finds the maximum N, and returns T[max+1]. If no matching names exist it returns "T1".

(tabNames []string)

Source from the content-addressed store, hash-verified

202// positive integer, finds the maximum N, and returns T[max+1]. If no matching
203// names exist it returns "T1".
204func getNextTabName(tabNames []string) string {
205 maxNum := 0
206 for _, name := range tabNames {
207 m := tabNameRe.FindStringSubmatch(name)
208 if m == nil {
209 continue
210 }
211 n, err := strconv.Atoi(m[1])
212 if err != nil || n <= 0 {
213 continue
214 }
215 if n > maxNum {
216 maxNum = n
217 }
218 }
219 return "T" + strconv.Itoa(maxNum+1)
220}
221
222// returns tabid
223func CreateTab(ctx context.Context, workspaceId string, tabName string, activateTab bool, isInitialLaunch bool) (string, error) {

Callers 1

CreateTabFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected