@@ -45,9 +45,14 @@ func runSwitch(cfg *config.Config) error {
4545 // Build options in reverse order (top of stack first) with 1-based numbering.
4646 n := len (s .Branches )
4747 options := make ([]string , n )
48+ currentBranch := result .CurrentBranch
49+ var defaultOpt string
4850 for i := 0 ; i < n ; i ++ {
4951 branchIdx := n - 1 - i
5052 options [i ] = fmt .Sprintf ("%d. %s" , branchIdx + 1 , s .Branches [branchIdx ].Branch )
53+ if s .Branches [branchIdx ].Branch == currentBranch {
54+ defaultOpt = options [i ]
55+ }
5156 }
5257
5358 var selectFn func (prompt , def string , opts []string ) (int , error )
@@ -60,7 +65,7 @@ func runSwitch(cfg *config.Config) error {
6065 }
6166 }
6267
63- selected , err := selectFn ("Select a branch in the stack to switch to:" , "" , options )
68+ selected , err := selectFn ("Select a branch in the stack to switch to:" , defaultOpt , options )
6469 if err != nil {
6570 if isInterruptError (err ) {
6671 clearSelectPrompt (cfg , len (options ))
@@ -79,8 +84,6 @@ func runSwitch(cfg *config.Config) error {
7984 // Map selection back: index 0 in options = branch at n-1, etc.
8085 branchIdx := n - 1 - selected
8186 targetBranch := s .Branches [branchIdx ].Branch
82-
83- currentBranch := result .CurrentBranch
8487 if targetBranch == currentBranch {
8588 cfg .Infof ("Already on %s" , targetBranch )
8689 return nil
0 commit comments